CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2009
    Posts
    30

    Issue with GetProcAddress need input

    Hi,

    I'm working on a VBA project for work, and I'm having issues with GetProcAddress and LoadLibrary (But this works in a few directories, not where I need it from)

    Below is the code, and just a simple call to get the address of a function, but I keep getting a return of (0).

    Any input would be greatly appreciated.

    Code:
    This is the header of the C file.
    
    #ifdef EPIQUTIL_EXPORTS
    #define EPIQUTIL_API __declspec(dllexport)
    #else
    #define EPIQUTIL_API __declspec(dllimport)
    #endif
    
    // The functions needed to interface with VBA EPIQ Utils
    
    // This function must be called before any other function.
    extern "C" EPIQUTIL_API void EPIQ_init(const long MyWaitTime);
    
    
    _________________________________________
    This is the calls in VBA
    
        Dim hinstLib As LongPtr
        Dim hFreeLib As LongPtr
        Dim szFunc As String
        
        hinstLib = 0
        ProcAdd = 0
        hFreeLib = 0
        ' Get a handle to the DLL module.
    
    
            hinstLib = LoadLibrary("C:\Users\epperbx\source\repos\EPIQ Util DLL\Debug\EPIQ Util.dll")
     
            ' If the handle is valid, try to get the function address.
        
                ProcAdd = GetProcAddress(hinstLib, "EPIQ_Init")
                
                hFreeLib = FreeLibrary(hinstLib)
    Am I missing a pointer to the function like in C/C++ in front of GetProcAddress? In any case, what ever input you can provide would be greatly appreciated.


    I realized I had an UPPER CASE for EPIQ_init. Corrected that but still have the same issue.
    Last edited by funkmonkey; March 6th, 2025 at 03:49 PM.

  2. #2
    Join Date
    Feb 2009
    Posts
    30

    Re: Issue with GetProcAddress need input

    Quote Originally Posted by funkmonkey View Post
    Hi,

    I'm working on a VBA project for work, and I'm having issues with GetProcAddress and LoadLibrary (But this works in a few directories, not where I need it from)

    Below is the code, and just a simple call to get the address of a function, but I keep getting a return of (0).

    Any input would be greatly appreciated.

    Code:
    This is the header of the C file.
    
    #ifdef EPIQUTIL_EXPORTS
    #define EPIQUTIL_API __declspec(dllexport)
    #else
    #define EPIQUTIL_API __declspec(dllimport)
    #endif
    
    // The functions needed to interface with VBA EPIQ Utils
    
    // This function must be called before any other function.
    extern "C" EPIQUTIL_API void EPIQ_init(const long MyWaitTime);
    
    
    _________________________________________
    This is the calls in VBA
    
        Dim hinstLib As LongPtr
        Dim hFreeLib As LongPtr
        Dim szFunc As String
        
        hinstLib = 0
        ProcAdd = 0
        hFreeLib = 0
        ' Get a handle to the DLL module.
    
    
            hinstLib = LoadLibrary("C:\Users\epperbx\source\repos\EPIQ Util DLL\Debug\EPIQ Util.dll")
     
            ' If the handle is valid, try to get the function address.
        
                ProcAdd = GetProcAddress(hinstLib, "EPIQ_Init")
                
                hFreeLib = FreeLibrary(hinstLib)
    Am I missing a pointer to the function like in C/C++ in front of GetProcAddress? In any case, what ever input you can provide would be greatly appreciated.


    I realized I had an UPPER CASE for EPIQ_init. Corrected that but still have the same issue.



    UPDATE: I setup loadlibrary and getprocaddress to obtain a messageboxW and a pointer from getprocaddress was accomplished. So I thought it was the DLL proc issue, but now I'm sure. Can someone review my DLL code and enlighten me as to what could be wrong?

    Code:
    #ifdef EPIQUTIL_EXPORTS
    #define EPIQUTIL_API __declspec(dllexport)
    #else
    #define EPIQUTIL_API __declspec(dllimport)
    #endif
    
    // The functions needed to interface with VBA EPIQ Utils
    
    // This function must be called before any other function.
    extern "C" EPIQUTIL_API void EPIQ_init(const long MyWaitTime);

  3. #3
    Join Date
    Nov 2018
    Posts
    149

    Re: Issue with GetProcAddress need input

    > I realized I had an UPPER CASE for EPIQ_init. Corrected that but still have the same issue.
    Are you sure?

    Because both your posts show the case to be still a mix of lower and upper.

    And start calling GetLastError every time something doesn't work, so you can find out more information.

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