Delphi如何调用C++写的Dll
C源码extern"C"__declspec(dllexport)VOIDWINAPIPipeOpen(PipeStruct*lppipe,LPCSTRszProcFil...
C 源码
extern "C" __declspec(dllexport) VOID WINAPI PipeOpen(PipeStruct *lppipe, LPCSTR szProcFile);
VOID WINAPI PipeOpen(PipeStruct *lppipe, LPCSTR szProcFile) {
lppipe->Open(szProcFile);
}
VOID WINAPI PipeClose(PipeStruct *lppipe) {
lppipe->Close();
}
LPSTR WINAPI PipeLineInput(PipeStruct *lppipe) {
static char szBuffer[LINE_INPUT_MAX_CHAR];
if (lppipe->LineInput(szBuffer)) {
return szBuffer;
} else {
return NULL;
}
}
VOID WINAPI PipeLineOutput(PipeStruct *lppipe, LPCSTR szLineStr) {
lppipe->LineOutput(szLineStr);
}
#endif 展开
extern "C" __declspec(dllexport) VOID WINAPI PipeOpen(PipeStruct *lppipe, LPCSTR szProcFile);
VOID WINAPI PipeOpen(PipeStruct *lppipe, LPCSTR szProcFile) {
lppipe->Open(szProcFile);
}
VOID WINAPI PipeClose(PipeStruct *lppipe) {
lppipe->Close();
}
LPSTR WINAPI PipeLineInput(PipeStruct *lppipe) {
static char szBuffer[LINE_INPUT_MAX_CHAR];
if (lppipe->LineInput(szBuffer)) {
return szBuffer;
} else {
return NULL;
}
}
VOID WINAPI PipeLineOutput(PipeStruct *lppipe, LPCSTR szLineStr) {
lppipe->LineOutput(szLineStr);
}
#endif 展开
1个回答
展开全部
静态引用法:
procedure PipeOpen(lppipe:PipeStruct;szProcFile:PChar);stdcall;external '<被调用的Dll名字.dll>';
动态引用法:
var
hDll:DWORD;//声明Dll句柄
PipeOpen:procedure(lppipe:pointer{PipeStruct};szProcFile:PChar);stdcall;//声明被调用过程
hDll:=LoadLibrary('<被调用的Dll名字.dll>');//加载Dll获取句柄
PipeOpen:=GetProcAddress(hDll,'PipeOpen'); //获取Dll函数地址
PipeOpen( );//调用过程(参数根据您的功能)
FreeLibrary(hDll);//用完Dll后释放
procedure PipeOpen(lppipe:PipeStruct;szProcFile:PChar);stdcall;external '<被调用的Dll名字.dll>';
动态引用法:
var
hDll:DWORD;//声明Dll句柄
PipeOpen:procedure(lppipe:pointer{PipeStruct};szProcFile:PChar);stdcall;//声明被调用过程
hDll:=LoadLibrary('<被调用的Dll名字.dll>');//加载Dll获取句柄
PipeOpen:=GetProcAddress(hDll,'PipeOpen'); //获取Dll函数地址
PipeOpen( );//调用过程(参数根据您的功能)
FreeLibrary(hDll);//用完Dll后释放
追问
不行啊 ,你邮箱是多少啊 我不源代码给你发过去,你帮看看
追答
815820833@qq.com
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询