一個關於奇怪的dll的問題...... ( 积分: 100 )

  • 主题发起人 主题发起人 jxgangzhao
  • 开始时间 开始时间
J

jxgangzhao

Unregistered / Unconfirmed
GUEST, unregistred user!
dll 代碼如下:
library Encrypt;
uses
SysUtils,
Classes,
penniesint in 'penniesint.pas';
function encryptHex
(source:pchar;outstr:pchar;Encrypt:boolean;key:pchar):word;stdcall;
begin
astr:=source;
outstr:=source;
end;
exports
encryptHex;
begin
end.

調用過程為:
proceudre dllResultTest()
var
source,outstr,key:string;
begin
source:='1000';
encrypthex(pchar(source),pchar(outstr),true,pchar('123'));
end;

penniesint.pas為:
unit penniesint;
interface
function encryptHex(
source:pchar;outstr:pchar;Encrypt:boolean;key:pchar):word;stdcall;
implementation
function encryptHex;external 'Encrypt.dll' name 'encryptHex';
問題點:
outstr輸出的字符不等於'1000'.請問這是為什麼.應該怎麼寫才對.
 
dll 代碼如下:
library Encrypt;
uses
SysUtils,
Classes,
penniesint in 'penniesint.pas';
function encryptHex
(source:pchar;outstr:pchar;Encrypt:boolean;key:pchar):word;stdcall;
begin
astr:=source;
outstr:=source;
end;
exports
encryptHex;
begin
end.

調用過程為:
proceudre dllResultTest()
var
source,outstr,key:string;
begin
source:='1000';
encrypthex(pchar(source),pchar(outstr),true,pchar('123'));
end;

penniesint.pas為:
unit penniesint;
interface
function encryptHex(
source:pchar;outstr:pchar;Encrypt:boolean;key:pchar):word;stdcall;
implementation
function encryptHex;external 'Encrypt.dll' name 'encryptHex';
問題點:
outstr輸出的字符不等於'1000'.請問這是為什麼.應該怎麼寫才對.
 
是沒人知道嗎?還是沒人對這個問題感興趣.怎麼沒人回答.
 
function encryptHex (source:pchar;var outstr:pchar;Encrypt:boolean;key:pchar):word;stdcall;
 
pchar在dll中传递似乎没有那么简单
魏红的代码可能在大部分情况没有问题,但有时可能出现奇怪错误
我以前遇到这类问题,看看这里:
http://delphibbs.com/delphibbs/dispq.asp?lid=2646321
 
astr的声明在哪?
 
多人接受答案了。
 
后退
顶部