请教C++哪个函数能够得到进程中DLL的内存基址

2025-04-08 19:54:59
推荐回答(2个)
回答(1):

#include "windows.h"
#include

void main(){
typedef int(*pMax)(int a, int b);
typedef int(*pMin)(int a, int b);
typedef bool(*pcim2scada)(char* cimid, char** scada);
HINSTANCE HDLL;
HDLL=LoadLibrary(L"MyDll.dll");//加载动态链接库MyDll.dll文件;
pMax Max=(pMax)GetProcAddress(HDLL,"Max");
pMin Min=(pMin)GetProcAddress(HDLL,"Min");
pcim2scada cim2scada=(pcim2scada)GetProcAddress(HDLL,"cim2scada");
int a = Max(5, 12);

char cimId[] = "aaaaaa";
char * scadaId = "";
bool b = cim2scada(cimId, &scadaId);

printf("Max结果为%d",a);
printf("cimId:%s, scadaId:%s", cimId, scadaId);
FreeLibrary(HDLL);//卸载MyDll.dll文件;
}

回答(2):

Windows API:
GetModuleHandle