windows - Using functions in a dll in c++? -
i have created dll in c++ using __declspec(dllexport) before class name. when try use in c++ program crashes in between. when debugged found function pointer not initialized @ all. me plz.
using namespace std; typedef void (*func)(); int main() { func funcpointer; hinstance xyz = loadlibrary(text("c:\\extra\\dll\\dlls\\debug\\random.dll")); funcpointer = (func)getprocaddress(xyz,"get it"); funcpointer(); return 0; }
thanks in advance.
first of use dumpbin /exports yourdll.dll
see if function expect exported exported , exact name. if find name "mangled" need declare function extern "c"
. once have determined name way go correct. check hinstance xyz
became not null after loading library. if null robably don't reach dll ( not in search path ) or reason can't load example because dependencies missing.
Comments
Post a Comment