如何用C++ Builder调用DLL函数
DLL函数如下:
/* 用途: 获取 MAC值输入:CustName输出: MAC返回值: True表示获取成功, False表示获取失败*/
function GetMACByCust(CustName, MAC: PChar): boolean; stdcall;
如何调用Dll,输入CustName,获取MAC,请高手帮帮忙!谢谢!
[解决办法]
本帖最后由 ccrun 于 2013-07-20 10:49:54 编辑
typedef bool (__stdcall *GETMACBYCUST)(char *, char *);
HINSTANCE hDll = LoadLibrary("dll文件名");
if (hDll)
{
GETMACBYCUST GetMACByCust = (GETMACBYCUST)GetProcAddress(hDll, "GetMACByCust");
if (GetMACByCust)
{
char Cust[256], MAC[256];
memset(Cust, 0x0, sizeof(Cust));
memset(MAC, 0x0, sizeof(MAC));
// 或者这里需要初始化一下Cust?
GetMACByCust(Cust, MAC);
// ...
}
FreeLibrary(hDll);
}