8th May 2006, 06:47 AM | #1 |
Junior Member
Junior member
Join Date: Apr 2006
Posts: 3
|
How can I Export DllRegisterServer function in VC++?
Hi Every one,
I'm programming in VC++ and I created a dll(MFC dll) with VC++,in this dll I'd like to have a function that export to out,I can do it ,but when I declare DllRegisterServer function I can't export it. My code is same as folowing code: __declspec(dllexport) STDAPI DllRegisterServer(void); how can I export DllRegisterServer or DllUnregisterServer function that implemented in a dll ? Please help me. Best Regards. Orchid |
8th May 2006, 05:22 PM | #2 |
Member
Expert member
Join Date: Aug 2003
Location: Eslöv, Sweden
Posts: 93
|
A simple
Code:
STDAPI DllRegisterServer(void) { } 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(); } |
9th May 2006, 02:50 AM | #3 | |
Junior Member
Junior member
Join Date: Apr 2006
Posts: 3
|
How can I export DllUnregisterServer in VC++?
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:
|
|
|
|