在动态连接库里,string 怎样转换成 pchar . 急急!!!(200分)

  • 主题发起人 主题发起人 pb
  • 开始时间 开始时间
P

pb

Unregistered / Unconfirmed
GUEST, unregistred user!
在动态连接库里,string 怎样转换成 pchar .

调用dll时, string 怎样转换成 pchar. pchar怎样转换成 string.

 
pchar('123')传进出
看看下面的程序
FUNCTION CMPFILE(FILENAME1:PCHAR;FILENAME2:PCHAR):INTEGER;STDCALL;
VAR
ST1,ST2,
SB1,SB2
:STRING;
F1,F2:FILE;
BEGIN

ST1:=STRING(FILENAME1);
ST2:=STRING(FILENAME2)
{convert pchar type to string}
{MESSAGEBOX(0,PCHAR(ST1+ST2),'COMP FILES',$40);}
ASSIGNFILE(F1,ST1);
ASSIGNFILE(F2,ST2);
RESET(F1,1);
RESET(F2,1);
IF FILESIZE(F1)<>FILESIZE(F2) {compare file length first }
THEN
BEGIN
CLOSEFILE(F1);
CLOSEFILE(F2);
CMPFILE:=0;
EXIT;
END;
SETLENGTH(SB1,FILESIZE(F1));
SETLENGTH(SB2,FILESIZE(F2))
{init tow string length}
BLOCKREAD(F1,SB1[1],FILESIZE(F1));
BLOCKREAD(F2,SB2[1],FILESIZE(F2));
IF SB1<>SB2
THEN
CMPFILE:=0 {if files are different then return 0}
ELSE
CMPFILE:=-1
{if files are same then return -1}
CLOSEFILE(F1);
CLOSEFILE(F2);
END;
 
Copies a Pascal string to a null-terminated string.

Unit

Sysutils

Category

string handling routines (null-terminated)

function StrPCopy(Dest: PChar
const Source: string): PChar;

Description

StrPCopy copies a Pascal-type string Source into a null-terminated string Dest. It returns a pointer to Dest.

StrPCopy does not perform any length checking.

The destination buffer must have room for at least Length(Source)+1 characters.
 
1.pchar(string) string 转换为pchar
2.string(pchar) pchar 转换为string
 
接受答案了.
 

Similar threads

D
回复
0
查看
825
DelphiTeacher的专栏
D
D
回复
0
查看
831
DelphiTeacher的专栏
D
D
回复
0
查看
664
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部