I have a C# form application…i created a Dll…now i want to launch that dll using this program. how do i do it?
#include <windows.h>
typedef int (*function1_ptr) ();
function1_ptr function1=NULL;
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
HMODULE myDll = LoadLibrary("Dll1.dll");
if(myDll!=NULL) {
function1 = (function1_ptr) GetProcAddress(myDll,"function1");
if(function1!=NULL)
function1();
else
exit(4);
FreeLibrary(myDll);
}
else
exit(6);
GetLastError();
return 0;
}
This was the code used to test my dll…i.e Dll1.dll..function1 was the function within dll1.dll…..can i do something similar with the C# code???
To do what your code example does, use the following C# code:
The above example is a C# program that calls a function in non .NET based DLL.
The example below is a C# program that calls a function in a .NET based DLL.
Is any of the the 2 examples what you want?
Or are you trying to call a C# function in a DLL from your example code?