解决方案 »
- CXGRID 日期问题
- 使用线程遇到难题,请教高手帮助
- 怎么让TStringGrid单元格的文字居中?
- 和小I聊了一下
- 请问用Delphi编写的Dll如果要返回字符串类型,而且要提供给VC使用该怎么办?
- 升级了!散分了!
- 据说是一个比较简单的问题!!!给100分吧!进来拿分吧!
- 怎样把表合并啊?数据库为SQL Server2000
- A程序怎么隐藏B程序的界面,按下B程序的某些Tbottom,或是向Tedit写内容
- delphi7 安装 fastreports2.51出错,求大神解答
- teechart中Series的Marks显示的问题
- 帮忙解释一句代码。对clientdataset的data属性和datarequest方法不理解
试下这样var
MyChar:Pchar; new(MyChar);
StrPCopy(Mychar,userId);
读的话用 StrPas(Pchar);返回string 感觉delphi的强制类型转换很有问题, 记得转换前记得把string trim下
1、Delphi9使用PAnsiChar才能够与C++的char*对应
TRegister = function(userId, proxy, pwd: PAnsiChar): Integer; cdecl;
2、defphi PAnsiChar变量赋值之前需要new(charUserId )<span style="color:#FF0000"><strong>下面代码测试通过:</strong></span>
function TPhoneDllLoader.telRegister(userId, pwd, proxy: string): Integer;
var
telRegisterFunc: TRegister;
outcome: Integer; charUserId, charPwd, charProxy: PAnsiChar;
begin
new(charUserId);
new(charPwd);
new(charProxy); StrPCopy(charUserId,userId);
StrPCopy(charPwd,pwd);
StrPCopy(charProxy,proxy);
if hDLL <> 0 then
begin
telRegisterFunc := GetProcAddress(hDLL, 'registe');
outcome := telRegisterFunc(charUserId, charProxy, charPwd);
if outcome <> 0 then
begin
ShowMessage('registe process error.');
end;
end;
end;
function TPhoneDllLoader.telRegister(userId, pwd, proxy: AnsiString): Integer;
var
telRegisterFunc: TRegister;
outcome: Integer; charUserId:^PAnsiChar;
charProxy: ^PAnsiChar;
charPwd: ^PAnsiChar;
begin
New(charUserId);
charUserId^ := PAnsiChar(userId); New(charPwd);
charPwd^ := PAnsiChar(pwd); New(charProxy);
charProxy^ := PAnsiChar(proxy); if hDLL <> 0 then
begin
telRegisterFunc := GetProcAddress(hDLL, 'registe');
outcome := telRegisterFunc(charUserId^, charProxy^, charPwd^);
if outcome <> 0 then
begin
ShowMessage('registe process error.');
end;
end; Dispose(charUserId);
Dispose(charPwd);
Dispose(charProxy);
end;