c语言中通过符号表调用动态链接库

新建一个控制台程序,将动态链接库文件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;
}

编译执行可以看到如下效果
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/chendongpu/article/details/121351883