How to call a Dll
-
i want to know how to call a DLL and what is the difference between both 1.cocreate 2.Import dll Thank you...
vikas da
tasumisra wrote:
i want to know how to call a DLL
You don't call a dll. You first load the dll and when this is succesfull you can retrieve the addresses of functions in the dll and call those functions.
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
i want to know how to call a DLL and what is the difference between both 1.cocreate 2.Import dll Thank you...
vikas da
Call no load yes. How to load a dynamic link library (DLL) into a Microsoft Visual C++ 6.0 project[^] And see Step by Step: Calling C++ DLLs from VC++ and VB - Part 4[^]( Hans explains for you four parts for dlls.) ;)
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )
-
i want to know how to call a DLL and what is the difference between both 1.cocreate 2.Import dll Thank you...
vikas da
tasumisra wrote:
1.cocreate
Do you mean
CoCreateInstance
[^]? BTW: What aboutDLL
's documentation [^]? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
i want to know how to call a DLL and what is the difference between both 1.cocreate 2.Import dll Thank you...
vikas da
There are two methods generally. One:Dynamic load DLL HINSTANCE hInst; //DLL2.dll must in current directory. //Implement on a button clicked event. hInst=LoadLibrary("DLL2.dll"); typedef int (*ADDPROC) (int a,int b); ADDPROC add=(ADDPROC)GetProcAddress(hInst,"Add"); if(!add) { MessageBox("Failed to get address!"); return; } int ret=add(5,3); CString str; str.Format("%d",ret); MessageBox(str); Two:Static load DLL First place DLL2.dll and DLL2.lib into current directory, then set project/settings/Link to load DLL2.lib _declspec(dllimport) int add(int a,int b); void CDLL2TestDlg::OnButton1() { int a=add(5,5);//use this method from dll }
studing is processing in this life.