调用标准DLL的问题
我用VC显式调用一个标准DLL,出现一个编译错误,请高手帮忙解决
源码如下:
// VCTest.cpp : Defines the entry point for the console application.
//
#include "WinShellOper.h"
int main(int argc, char* argv[])
{
char c;
DWORD i;
BOOL res;
HINSTANCE hDll=LoadLibrary("WinShellOper.dll"); //显式调用WinShellOper.dll
if (hDll==NULL)
{
printf("load library fail \n");
}
else
{
printf("load library success \n");
pfDisableShell = (pfDisableShell)GetProcAddress(hDll,"disableShell");
if (pfDisableShell==NULL)
{
printf("load function \"disableShell\" fail\n");
FreeLibrary(hDll);
return 0;
}
else
{
res=pfDisableShell();
if (res!=NULL)
{
printf("execute function \"disableShell\" success\n");
printf("please input a letter to continue\n");
scanf("%c",&c);
}
else
{
printf("execute function \"disableShell\" fail\n");
FreeLibrary(hDll);
return 0;
}
}//if pfDisableShell
pfEnableShell=(pfEnableShell)GetProcAddress(hDll,"enableShell");
if (pfEnableShell==NULL)
{
printf("load function \"enableShell\" fail");
FreeLibrary(hDll);
return 0;
}
else
{
res=pfEnableShell();
if (res!=NULL)
{
printf("execute function \"enableShell\" success\n");
}
else
{
printf("execute function \"enableShell\" fail\n");
FreeLibrary(hDll);
return 0;
}
}//if pfEnableShell
printf("please input 0~4 to shutdown,reboot,logoff,force,poweroff your computer\n input 5 to exit");
scanf("%d",&i);
if (i==5)
{
FreeLibrary(hDll);
return 0;
}
pfDoShutDown2K=(pfDpShutDown2K)GetProcAddress(hDll,"doShutDown2K");
if (pfDoShutDown2K==NULL)
{
printf("load function \"doShutDown2K\" fail");
FreeLibrary(hDll);
return 0;
}
else
{
res=pfDoShutDown2K(i);
if (res!=NULL)
{
printf("execute function \"doShutDown2K\" success\n");
}
else
{
printf("execute function \"doShutDown2K\" fail\n");
FreeLibrary(hDll);
return 0;
}
}//if pfDoShutDown2K
} //if (hDll==NULL)
FreeLibrary(hDll);
return 1;
}
//WinShellOper.h
#include "StdAfx.h"
typedef __declspec(dllimport) BOOL (__stdcall *pfDisableShell)(void);
typedef __declspec(dllimport) BOOL (__stdcall *pfEnableShell)(void);
typedef __declspec(dllimport) BOOL (__stdcall *pfDoShutDown2K)(DWORD);
编译后出现错误信息
fatal error C1010: unexpected end of file while looking for precompiled header directive