I have the .def file, .lib file, the .dll, the source files.
It's using WINAPI DllMain, all its functions follow that.
It's like this:
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C"
{
int WINAPI DoSomething() { return -1; }开发者_开发技巧
int WINAPI DOSOMETHIGNELSE!() { return 202020; }
};
IN the project settings linker I added the .lib file. There is no header file for the actual functions in the extern "C" part.
I include windows.h try to call DoSomething() but doesnt know what it is.
I'm not sure exactly what you're asking for, but I think at the least you'll need to create a .h
file for client code to include so it can call functions in the the DLL - otherwise how will the compiler know what the name DoSomething
is?
The header file should probably look something like:
#ifndef DOSOMETHING_H
#define DOSOMETHING_H
#ifdef __cplusplus
extern "C"
{
#endif
int WINAPI DoSomething(void);
// I commented out the 2nd function because I don't think the `!` character
// could ever be valid there
//int WINAPI DOSOMETHIGNELSE!();
#ifdef __cplusplus
}
#endif
#endif /* DOSOMETHING_H */
精彩评论