Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6201301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:31:44+00:00 2026-05-24T04:31:44+00:00

I have to use this external functions GetOpenedFiles (more info to: http://www.codeproject.com/KB/shell/OpenedFileFinder.aspx ) into

  • 0

I have to use this external functions “GetOpenedFiles” (more info to: http://www.codeproject.com/KB/shell/OpenedFileFinder.aspx) into my C# application.
I don’t know as I can write a wrapper of this function:

void GetOpenedFiles(LPCWSTR lpPath, OF_TYPE Filter, OF_CALLBACK CallBackProc, UINT_PTR pUserContext);

ORIGINAL C++ CODE (OpenFilefinder.h)

enum OF_TYPE
{
    FILES_ONLY = 1,
    MODULES_ONLY = 2,
    ALL_TYPES = 3
};

struct OF_INFO_t
{
    DWORD dwPID;
    LPCWSTR lpFile;
    HANDLE hFile;
};

typedef void (CALLBACK* OF_CALLBACK)(OF_INFO_t OpenedFileInf0, UINT_PTR uUserContext );


extern "C" __declspec(dllexport) void ShowOpenedFiles( LPCWSTR lpPath );
extern "C" __declspec(dllexport) void GetOpenedFiles( LPCWSTR lpPath, 
                                                      OF_TYPE Filter,
                                                      OF_CALLBACK CallBackProc,
                                                      UINT_PTR pUserContext );

MY C# APPLICATION:

    public enum OF_TYPE : int
    {
        FILES_ONLY = 1,
        MODULES_ONLY = 2,
        ALL_TYPES = 3
    }

    public struct OF_INFO_t
    {
        ?????? dwPID;
        ?????? lpFile;
        ?????? hFile;
    }

    [DllImport("OpenFileFinder.dll", EntryPoint = "GetOpenedFiles")]
    static extern void GetOpenedFiles(??????? lpPath, OF_TYPE filter, ????? CallBackProc, ????? pUserContext);

How can I use this dll function correctly in my C# app?

EDIT:

This is my latest snippet, but never invoke callback function:

namespace Open64
{
    class Program
    {

        public Program()
        {
            GetOpenedFiles("C:\\", OF_TYPE.ALL_TYPES, CallbackFunction, UIntPtr.Zero);
        }

        //void GetOpenedFiles(LPCWSTR lpPath, OF_TYPE Filter, OF_CALLBACK CallBackProc, UINT_PTR pUserContext);

        public enum OF_TYPE : int
        {
            FILES_ONLY = 1,
            MODULES_ONLY = 2,
            ALL_TYPES = 3
        }

        public struct OF_INFO_t
        {
            Int32 dwPID;
            String lpFile;
            IntPtr hFile;
        }

        public delegate void CallbackFunctionDef(OF_INFO_t info, IntPtr context);

        [DllImport("OpenFileFinder.dll", EntryPoint = "GetOpenedFiles")]
        static extern void GetOpenedFiles(string lpPath, OF_TYPE filter, CallbackFunctionDef CallBackProc, UIntPtr pUserContext);

        public void CallbackFunction(OF_INFO_t info, IntPtr context)
        {
            Console.WriteLine("asd");
        }

        [STAThread]
        static void Main()
        {
            new Program();
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:31:45+00:00Added an answer on May 24, 2026 at 4:31 am
    public struct OF_INFO_t
    {
       Int32 dwPID;
       String lpFile;
       IntPtr hFile;
    }
    
    public delegate void CallbackFunctionDef(OF_INFO_t info, UIntPtr context);
    
    [DllImport("OpenFileFinder.dll", EntryPoint = "GetOpenedFiles")]
    static extern void GetOpenedFiles(string lpPath, OF_TYPE filter, CallbackFunctionDef CallBackProc, UIntPtr pUserContext);
    

    EDIT: Here’s the complete program

    class Program
    {
        public Program()
        {
            GetOpenedFiles("C:\\", OF_TYPE.ALL_TYPES, CallbackFunction, UIntPtr.Zero);
            Console.ReadKey();
        }
    
        //void GetOpenedFiles(LPCWSTR lpPath, OF_TYPE Filter, OF_CALLBACK CallBackProc, UINT_PTR pUserContext);
    
        public enum OF_TYPE : int
        {
            FILES_ONLY = 1,
            MODULES_ONLY = 2,
            ALL_TYPES = 3
        }
    
        [StructLayout(LayoutKind.Sequential,CharSet = CharSet.Unicode)]
        public struct OF_INFO_t
        {
            public Int32 dwPID;
            public String lpFile;
            public IntPtr hFile;
        }
    
        public delegate void CallbackFunctionDef(OF_INFO_t info, IntPtr context);
    
        [DllImport("OpenFileFinder.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "GetOpenedFiles")]
        static extern void GetOpenedFiles(string lpPath, OF_TYPE filter, CallbackFunctionDef CallBackProc, UIntPtr pUserContext);
    
        public void CallbackFunction(OF_INFO_t info, IntPtr context)
        {
            //List the files
            Console.WriteLine(info.lpFile);
        }
    
        [STAThread]
        static void Main()
        {
            new Program();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use an externel javascript file and i have this, function getdropdownvalue() { alert($(#<%=DLState.ClientID%>));
I have this use case of an xml file with input like Input: <abc
I have attempted to use this CSS to set the width of my form
I am working with a hexagonal grid. I have chosen to use this coordinate
I'm very much a vb person, but have had to use this id number
I use this bit of code to feed some data i have parsed from
I don't have any idea how to use this class in .net. Anyone wants
I have my Windows Application that accepts args and I use this in order
I have developed a simple library in Ruby and need to use this in
I have searched high and low for documentation on how to use this feature.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.