Answer the question
In order to leave comments, you need to log in
How to call functions from someone else's DLL?
I have someone else's dll. Also there is an example on VB6.0 of usage of this dll. dll is not a COM server.
I eventually need to use jni to call this dll from java.
But how to call this dll from c++ to write a jni wrapper?
Answer the question
In order to leave comments, you need to log in
Load the DLL, find the functions you need and call them :-)
Very schematically, something like this:
// указатель на функцию, которая принимает параметр char* и возвращает int
typedef int (__cdecl *_your_function)(char *auth_st);
_your_function YourFunction;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HINSTANCE hLib = LoadLibrary("Path_to_DLL");
YourFunction = (_your_function)GetProcAddress((HMODULE)hLib, "Your_Function_name");
if(YourFunction == NULL) {
//something wrong
}
int res = YourFunction ("some string");
}
The only thing in my case in the ad
replaced __cdecl*
with __stdcall*
and everything worked.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question