When I called following function from main, I noticed that function was called and executed properly till just before return. I could not understand why but after executing return, the whole program is broken with windows error message. Can someone help me out? I16 InitCPCI(U16 Card_Type, U16 Card_Number) { I16 status; if(_RegisterCard=(RegisterCard)GetProcAddress(hInstLibrary,"Register_Card")) { //if ((_RegisterCard(PCI_7432,0))) return (0); //else std::cout
ReplyHINSTANCE hInstLibrary = LoadLibrary("Dll1.dll","Dll2.dll","Dll3.dll",Dll4.dll"); In above mentioned code i have loaded 4 dll's in a single load library and each dll has four function and all the dll contain same functions in it..i want to run the four function par alley by loading all this 4 dll files ..how to do it plz tell me the code asap....
ReplyI am beginner in C++ and this for me.
ReplyI was searching for methods to export functions from DLL and usage of GetProcAddress. This article really helped. Keep writing such articles :)
ReplyThanks SO much. I have been trying to learn how to create and call a DLL for a while. All the other guides are so complicated and attempt at doing "Fancy" things that a newbie like me can't make any sense of it. Your guide shows me how to use the basics so that I can replace simple functions with what I need my DLL's to perform. Once again, thank you. Keep up the good tutorials.
Replyexcellent, only error I can see is if the dll is not in current dir or path worked fine for me.Reply
error C2491: 'Add' : definition of dllimport function not allowed error C2491: 'Function' : definition of dllimport function not allowed could anyone help on that?
Did you solve this?
probably because in DLLTutorial.cpp: #include "DLL_Tutorial.h" #define DLL_EXPORT should be changed to #define DLL_EXPORT #include "DLL_Tutorial.h" if you don't do that, DLL_Tutorial.h will not declare dllexport but dllimport
Yep, that helped. Thanks!
ReplyHi Masters of the language c++! I'm trying to make a simple dll and a teszt app for start in learning dll with the free borland c++ tools. The problem is that I have trying to do this about 2 week now and no success. Tryed several methods and nothing. Also I tryed to copy past this example but it's the same as the others. I try to explicitly load the dll - without the lib file. But it isn't find any of my exported functions. I generate a map file to get some info and it always has the function but it has 0 for address. Really it's no matter if i use the __declspec(dllexport) or the __export or the .def file it's the same resoult... Please help me!
I think i've got Turex from this ****, but the problem was in all cases that the compiler given the name @IncX$qi instead of my IncX... I just can't imagine why. I used impdef to extract the export information from my dll and it used this name so I inserted this to GetProcAddress and voila! The new questin is: Why???
Replyhi i did whatever you have specified I created a MouseHandle dll project in visual Studio 2005. i created the MouseHandle.h file as #ifndef _MOUSE_HANDLE_H_ #define _MOUSE_HANDLE_H_ #includeReply#include #if defined DLL_EXPORT #define DECLDIR __declspec(dllexport) #else #define DECLDIR __declspec(dllimport) #endif extern C { LRESULT CALLBACK MyMouseProc(int nCode,WPARAM wParam,LPARAM lParam) } #endif but on compiling it gives error error C2059: syntax error : 'string'
it was everything 101 I was looking for. GREAT JOB. Please continue to contribute.Reply