Go Back   AC3D Forums > Technical > AC3D Developers
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 8th May 2006, 06:47 AM   #1
Orchid
Junior Member
Junior member
 
Join Date: Apr 2006
Posts: 3
Default 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
Orchid is offline   Reply With Quote
Old 8th May 2006, 05:22 PM   #2
PerFnurt
Member
Expert member
 
Join Date: Aug 2003
Location: Eslöv, Sweden
Posts: 93
Default

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();
}
__________________
/Per

www.perfnurt.se
PerFnurt is offline   Reply With Quote
Old 9th May 2006, 02:50 AM   #3
Orchid
Junior Member
Junior member
 
Join Date: Apr 2006
Posts: 3
Default 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:
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();
}
Orchid is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 10:25 PM.


AC3D Forum
(C) Inivis Limited 2020