-
March 6th, 2025, 03:39 PM
#1
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.
-
March 6th, 2025, 08:07 PM
#2
Re: Issue with GetProcAddress need input
 Originally Posted by funkmonkey
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);
-
March 7th, 2025, 12:41 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|