Calling dll
-
Hi all, i have made a dll i want to use that dll in my program i have called the function of that dll using this code
typedef void (*function1_ptr) ();
function1_ptr function1=NULL;int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{HMODULE myDll = LoadLibrary("myfile.dll"); if(myDll) { function1 = (function1\_ptr) GetProcAddress(myDll,"function1"); if(function1) function1(); FreeLibrary(myDll); } return 0;
}
i have copied my dll in debug folder, but control is not going inside if statement... how should i do it.... can anybody please help me... Thanks in advance
To accomplish great things, we must not only act, but also dream; not only plan, but also believe.
-
Hi all, i have made a dll i want to use that dll in my program i have called the function of that dll using this code
typedef void (*function1_ptr) ();
function1_ptr function1=NULL;int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{HMODULE myDll = LoadLibrary("myfile.dll"); if(myDll) { function1 = (function1\_ptr) GetProcAddress(myDll,"function1"); if(function1) function1(); FreeLibrary(myDll); } return 0;
}
i have copied my dll in debug folder, but control is not going inside if statement... how should i do it.... can anybody please help me... Thanks in advance
To accomplish great things, we must not only act, but also dream; not only plan, but also believe.
Try giving full path in LoadLibrary.
HMODULE myDll = LoadLibrary("myfile.dll");
to something likeHMODULE myDll = LoadLibrary("C:\\Myproject\\debug\\myfile.dll");
-
Hi all, i have made a dll i want to use that dll in my program i have called the function of that dll using this code
typedef void (*function1_ptr) ();
function1_ptr function1=NULL;int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{HMODULE myDll = LoadLibrary("myfile.dll"); if(myDll) { function1 = (function1\_ptr) GetProcAddress(myDll,"function1"); if(function1) function1(); FreeLibrary(myDll); } return 0;
}
i have copied my dll in debug folder, but control is not going inside if statement... how should i do it.... can anybody please help me... Thanks in advance
To accomplish great things, we must not only act, but also dream; not only plan, but also believe.
What the error return code you are getting from LoadLibrary function?
-
Hi all, i have made a dll i want to use that dll in my program i have called the function of that dll using this code
typedef void (*function1_ptr) ();
function1_ptr function1=NULL;int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{HMODULE myDll = LoadLibrary("myfile.dll"); if(myDll) { function1 = (function1\_ptr) GetProcAddress(myDll,"function1"); if(function1) function1(); FreeLibrary(myDll); } return 0;
}
i have copied my dll in debug folder, but control is not going inside if statement... how should i do it.... can anybody please help me... Thanks in advance
To accomplish great things, we must not only act, but also dream; not only plan, but also believe.
GetProcAddress(myDll,"function1"); maybe the 2nd parameter is the key. you could use "dumpbin /exports myfile.dll" to check the exported functions' name. then,give the right name string. i think your dll should include .def file
modified on Tuesday, December 29, 2009 3:16 AM
-
Hi all, i have made a dll i want to use that dll in my program i have called the function of that dll using this code
typedef void (*function1_ptr) ();
function1_ptr function1=NULL;int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{HMODULE myDll = LoadLibrary("myfile.dll"); if(myDll) { function1 = (function1\_ptr) GetProcAddress(myDll,"function1"); if(function1) function1(); FreeLibrary(myDll); } return 0;
}
i have copied my dll in debug folder, but control is not going inside if statement... how should i do it.... can anybody please help me... Thanks in advance
To accomplish great things, we must not only act, but also dream; not only plan, but also believe.
Le@rner wrote:
but control is not going inside if statement...
Which one ? The one after the call to LoadLibrary or the one after the call to GetProcAddress ? If this is the second call, make sure that you have provided a module defintion file (.def file) as explained in the documentation[^]
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++