有如下程序:
// test1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
int main(int argc, char* argv[])
{
printf("Hello World!\n");
typedef int(*pSleep)(long sleepTime);
HINSTANCE hDLL;
pSleep psleep;
HDLL=LoadLibrary("D:\\广东省建设银行\Sleep\sleep\Debug\sleep.dll");//加载动态链接库sleep.dll文件;
psleep=(pSleep)GetProcAddress(hDLL,"sleep");
for (int i=0;i<3;i++){
printf("Sleeping for %d seconds\n", i);
psleep(300);
}
FreeLibrary(hDLL);//卸载MyDll.dll文件;
return 0;
}
编译是为何报这个错:
D:\广东省建设银行\Sleep\test1\test1.cpp(15) : error C2440: '=' : cannot convert from 'struct HINSTANCE__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.
test1.obj - 2 error(s), 0 warning(s)