我現在需要調用一個別人用Delphi寫好的DLL~
但沒有DLL原始碼~不知道對方怎麼編寫的,只知道
DLL : SVR.DLL
Class : A_Security
Function: GetCode(const AInitCode: WideString): WideString; safecall;
使用時要輸入4個數字~而函式會傳回另外4個數字而我VC++現在call DLL部份程式碼如下: HINSTANCE loadSVR;
typedef string(*HFUNC)(string); //C++沒有WideString,那我是要寫string嗎? loadSVR = LoadLibrary("SVR.DLL");
if (loadSVR != NULL)
{
HFUNC handleSVR = (HFUNC)GetProcAddress(loadSVR, "FuncTest");
if (handleSVR){
handleSVR('1234');
printf("OK GetProcAddress \n");
}
else
printf("ERROR on GetProcAddress \n");
FreeLibrary(loadSVR);
}
else
printf("ERROR on LoadLibrary \n");
出現7個ERROR~指向
typedef string(*HFUNC)(string);
HFUNC handlePSVCB = (HFUNC)GetProcAddress(loadPSVCB, "FuncTest");
這兩行~主要錯誤顯示
error C2065: 'HFUNC' : undeclared identifier
error C2100: illegal indirection
error C2501: 'string' : missing storage-class or type specifiers
error C2065: 'handleSVR' : undeclared identifier請問~是我type對應不該用sting的關係嗎?
還是其他問題~又該如何解決??感謝!
但沒有DLL原始碼~不知道對方怎麼編寫的,只知道
DLL : SVR.DLL
Class : A_Security
Function: GetCode(const AInitCode: WideString): WideString; safecall;
使用時要輸入4個數字~而函式會傳回另外4個數字而我VC++現在call DLL部份程式碼如下: HINSTANCE loadSVR;
typedef string(*HFUNC)(string); //C++沒有WideString,那我是要寫string嗎? loadSVR = LoadLibrary("SVR.DLL");
if (loadSVR != NULL)
{
HFUNC handleSVR = (HFUNC)GetProcAddress(loadSVR, "FuncTest");
if (handleSVR){
handleSVR('1234');
printf("OK GetProcAddress \n");
}
else
printf("ERROR on GetProcAddress \n");
FreeLibrary(loadSVR);
}
else
printf("ERROR on LoadLibrary \n");
出現7個ERROR~指向
typedef string(*HFUNC)(string);
HFUNC handlePSVCB = (HFUNC)GetProcAddress(loadPSVCB, "FuncTest");
這兩行~主要錯誤顯示
error C2065: 'HFUNC' : undeclared identifier
error C2100: illegal indirection
error C2501: 'string' : missing storage-class or type specifiers
error C2065: 'handleSVR' : undeclared identifier請問~是我type對應不該用sting的關係嗎?
還是其他問題~又該如何解決??感謝!
解决方案 »
- 【高分跪求】CTreeCtrl目录树自定义排序问题
- GetAcceptExSockaddrs这个函数
- 控件类型更改的疑问
- [求VC高手]如何监视系统打印了什么
- 请教个关于ARP包的问题
- 串口编程问题,知道的请进!
- 请问如何设置CDateTimeCtrl的前景色和背景色(注意,不是下拉框)
- 用Delphi作ActiveX时调用SaveDialogh或是其他Dialog返回文件名为乱码,在线等待
- 怎样分离时间字符串?提取2002-10-23中的年月日,请具体针对这个字符串说明
- 在MSDN中怎么查对象的属性,我怎么只找到方法
- 客户端程序同时运行多个,怎么能依次向服务端发送connect
- 请教关于龚大侠串口助手V1.0 SCommT 的问题。
uses
SysUtils,
Classes;
function GetAuthCode(const AInitCode: WideString): WideString; safecall; external 'SVR.DLL';
function GetAuthCodeA(ti:String): pchar; stdcall;
var
s:string;
begin
s:=GetAuthCode(ti);
GetAuthCodeA:=pchar(s);
end;
exports
GetAuthCodeA;
begin
end.然後VC部分>>
#include <windows.h>
#include <stdio.h>
typedef char * (__stdcall *GetAuthCodeA)(char*); void main()
{
GetAuthCodeA GetCode;
HINSTANCE h=LoadLibrary("DelphiDLL.dll");
GetCode=(GetAuthCodeA)GetProcAddress(h,"GetAuthCodeA");
char *t=GetCode("1111");
printf("%s\n",t);
return;
}我有把DelphiDLL.dll和SVR.DLL都放到VC程式同一目錄下,現在compile部分是過了~但"無法找到程序輸入點(GetAuthCode)"請問該如何解決呢? >___<~急啊!