为什么编译通不过,该如何做
//----------------------------------Start of WNP.C-------------------------------------------
/*Create file exports.def with content:
EXPORTS
testlogoff
testlogon
*/
#include <windows.h>
#pragma comment(linker,"/export:test=_testlogoff@0")
#pragma comment(linker,"/export:test=_testlogon@0")
#pragma comment(linker,"/entry:DllEntry")
#pragma comment(linker,"/subsystem:windows")
#pragma comment(linker,"/align:4096")
#pragma comment(linker,"/dll")
#pragma comment(linker,"/base:1976369152")__declspec(dllexport) void __stdcall testlogoff(DWORD unknow)
{
MessageBox(NULL,"系统正在注销!","Winlogon Notification Package",MB_OK);
}__declspec(dllexport) void __stdcall testlogon(DWORD unknow)
{
MessageBox(NULL,"系统正在登陆!","Winlogon Notification Package",MB_OK);
}BOOL __stdcall DllEntry(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:break;
case DLL_THREAD_ATTACH:break;
case DLL_THREAD_DETACH:break;
case DLL_PROCESS_DETACH:break;
}return TRUE;
}
//----------------------------------End

解决方案 »

  1.   

    什么错误?
    #pragma comment(linker,"/export:test=_testlogoff@0")
    #pragma comment(linker,"/export:test=_testlogon@0")
    这两句可以注释掉,如果错误是:
    Unresolved External Symbol __chkesp
    那么你需要把编译参数中的/GZ去掉就可以了。
      

  2.   

    ompiling...
    test.cpp
    Linking...
       Creating library Debug/test.lib and object Debug/test.exp
    Debug/test.dll : warning LNK4086: entrypoint "_DllEntry" is not __stdcall with 12 bytes of arguments; image may not run
    LINK : error LNK2001: unresolved external symbol _DllEntry
    LIBCMTD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/test.dll : fatal error LNK1120: 2 unresolved externals
    Error executing link.exe.test.dll - 3 error(s), 1 warning(s)
      

  3.   

    你把程序里加一个main函数,空的什么都不写,注释掉最上面两句,再试试。