pchar('123')传进出
看看下面的程序
FUNCTION CMPFILE(FILENAME1
CHAR;FILENAME2
CHAR):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;