CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2001
    Posts
    260

    How to use Function After Calling GetProcAddress()

    Hi everyone.

    I don't know to use Function(...) after calling GetProcAddress(hmodule, Function(...))

    My code :
    DllImport("Kernel32.dll")]
    public static extern System.IntPtr LoadLibrary(string NameDLL);

    DllImport("Kernel32.dll")]
    public static extern System.IntPtr GetProcAddress( IntPtr hModule, string FunctionName);
    .......

    IntPtr temp = LoadLibrary("MyDLL.DLL");

    "?" = GetProcAddress( temp, "FunctionName");
    ....

    How to use "FunctionName" ?

    please tell me.

    thank you.

  2. #2
    Join Date
    Sep 2002
    Location
    DC Metro Area, USA
    Posts
    1,509
    I'm not sure how C# handles pointers, which is what you'd need to use for the return for GetProcAddress. This appears to be a workable way to dynamically load a function from a DLL:
    Code:
     
    public enum TernaryRasterOperations
    {
    // enums for raster ops
    }
    [DllImport("gdi32.dll", ExactSpelling=true, SetLastError=true)]
    public static extern Bool BitBlt(IntPtr hObject, int nXDest, int nYDest, 
    int nWidth, int nHeight, IntPtr hObjSource, int nXSrc, int nYSrc, TernaryRasterOperations dwRop);
    Then you just call the function...
    Last edited by bytz; December 18th, 2003 at 09:42 AM.
    bytz
    --This signature left intentionally blank--

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured