Win32 DLL def file question

  • Thread starter Thread starter Kid
  • Start date Start date
K

Kid

Hi

How can we export Win32 dll functions for dynamically LoadLibrary and
GetProceeAddress ?

I see VS MFC DLL project has a def file but Win32 DLL does not have one,
should we add a def file to VS Win32 DLL project , how can I do that ?

Thank you .
 
Cholo said:
There is another method to export functions apart from def file:
keyword __declspec(dllexport)

But if you want control over the exported names (no mangling) then you must
use a .def file.

Simply specify the file you create under Project Properties -> Linker ->
Input -> Module Definition File
 
But if you want control over the exported names (no mangling) then you
must use a .def file.

Not necessarily. Inside my dll cpp file, I have:
extern "C" __declspec(dllexport) IMyInterface* GetMyInterface()
{
return new MyInterfaceImpl();
}

No def file in sight. (Well, actually there is - but there are no exports
in it - I think I just forgot to remove it after using the wizard to
create the project)

To get the interface:
GETMYINTERFACE func = reinterpret_cast<GETMYINTERFACE>(GetProcAddress
(m_hDllInst, "GetMyInterface"));

where GETMYINTERFACE (defined in the header with IMyInterface) is:
typedef IMyInterface* (*GETMYINTERFACE)();

Now, if you want to specifically export a function at a set ordinal (is
that still possible, or am I just having win16 flashbacks?), you need a
def file.

Dave Connet
 
Back
Top