新建一个控制台程序,将动态链接库文件Test63.dll和Test63.lib文件拷贝到源文件统计目录下,在主程序中添加如下代码:
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#pragma comment(lib,"Test63.lib")
__declspec(dllimport) int MyMessageBox(char* lpText,char* lpCaption);
int main(int argc, char* argv[])
{
HMODULE hModule=LoadLibrary("Test63.dll");
MyMessageBox("by chen","Hello World!");
FreeLibrary(hModule);
return 0;
}
编译执行可以看到如下效果