相关疑难解决方法(0)

如何从Delphi中创建的DLL导入函数?

你能告诉我如何在我的C程序中使用以下功能吗?

Delphi DLL - 导出的函数:

function GetCPUID (CpuCore: byte): ShortString; stdcall;
function GetPartitionID(Partition : PChar): ShortString; stdcall;
Run Code Online (Sandbox Code Playgroud)

我没有该DLL的源代码,所以我必须使我的C程序适应该DLL,而不是相反.

我执行以下操作并得到错误

typedef char* (_stdcall *GETCPUID)(BYTE);
typedef char* (_stdcall *GETPID)(PCHAR);
GETCPUID pGetSerial;
GETPID pGetPID

HMODULE hWtsLib = LoadLibrary("HardwareIDExtractor.dll");
if (hWtsLib){
pGetSerial = (GETCPUID)GetProcAddress(hWtsLib, "GetCPUID");
char *str = (char*) malloc(1024);
str = pGetSerial((BYTE)"1");

pGetPID= (GETPID )GetProcAddress(hWtsLib, "GetPartitionID");
char *str1 = (char*) malloc(1024);
str1 = pGetPID("C:");
}
Run Code Online (Sandbox Code Playgroud)

谢谢

c delphi dll function

1
推荐指数
1
解决办法
2918
查看次数

标签 统计

c ×1

delphi ×1

dll ×1

function ×1