My code is same as your code .when I wrote following code and I compiled
my dll is compiled and its buid is succeeded and I didn't get any error.but after that I open my dll with "DLL Export Viewer" software,I see all of functions in my dll is exported except DllUnregisterServer and DllregisterServer .
The code in my dll is same as this:
In header file I wrote (for example in Myheader.h)
__declspec(dllexport) STDAPI DllUnregisterServer(void);
In Source file I wrote (for example in Mysource.cpp):
STDAPI DllUnregisterServer(void)
{
};
I build this dll and every thing is ok but I get two warning they are same as these :
1-warning C4518: '__declspec(dllexport)' : storage-class or type specifier(s) unexpected here; ignored
2-warning C4502: 'linkage specification' requires use of keyword 'extern' and must precede all other specifiers
Both of them is happend in this line "__declspec(dllexport) STDAPI DllUnregisterServer(void);"
After that I checked and opened my dll with "DLL Export Viewer" software and I saw DllUnregisterServer function isn't exported .I think mistake is in header file not in source file .If I write "STDAPI" before the "__declspec(dllexport)" in Myheader.h I get this error :
"error C2059: syntax error : '__declspec(dllexport)'
I can't find my mistake,if you have any idea I glad to hear it.
Best Regards.
Orchid
Quote:
Originally Posted by PerFnurt
A simple
Code:
STDAPI DllRegisterServer(void)
{
}
should do the trick.
Then you call it like:
Code:
typedef HRESULT (STDAPICALLTYPE* FuncDllRegisterServer)();
HMODULE hDll = AfxLoadLibrary(nameOfDll);
if (hDll==0)
{
// Failed to load the dll
}
else
{
FuncDllRegisterServer registerServer = (FuncDllRegisterServer)GetProcAddress(hDll, "DllRegisterServer");
if (registerServer == 0)
{
// DLL has no DllRegisterServer function
}
else
registerServer();
}
|