W
waterflow
Unregistered / Unconfirmed
GUEST, unregistred user!
我想从ini文件中读取信息,调用GetPrivateProfileString,但是好像有点问题
代码如下:
procedure TForm1.Button2Click(Sender: TObject);
var Sectname,KeyName:LPCTSTR;
; ; CurrentDir,FileName,DefaultStr,ResultString:String;
; ; aaWord;
begin
; ;CurrentDir:=GetCurrentDir();
; ;FileName:=CurrentDir+'/'+'test.ini';
; ;Showmessage(FileName);
; ;DefaultStr:='nil'+'/0';
; ;Sectname:=PChar(trim(Edit4.Text));
; ;KeyName:=PChar(trim(Edit5.text));
; ;aa:=GetPrivateProfileString(SectName,KeyName,PChar(DefaultStr),
; ; ; ; ; ; ; ; ; ; ; ; ; ; PChar(ResultString),100,Pchar(filename)
; ;
; ;if ResultString<>null then Edit6.text:=ResultString;
end;
在执行到GetPrivateProfileString时报错:
; ;accessviolation at address 77f87ffb in module 'ntdll.dll'
write of address d0404785
为何,我调用WritePrivateProfileString很正常,我的机器是nt 2000 server
谢谢
代码如下:
procedure TForm1.Button2Click(Sender: TObject);
var Sectname,KeyName:LPCTSTR;
; ; CurrentDir,FileName,DefaultStr,ResultString:String;
; ; aaWord;
begin
; ;CurrentDir:=GetCurrentDir();
; ;FileName:=CurrentDir+'/'+'test.ini';
; ;Showmessage(FileName);
; ;DefaultStr:='nil'+'/0';
; ;Sectname:=PChar(trim(Edit4.Text));
; ;KeyName:=PChar(trim(Edit5.text));
; ;aa:=GetPrivateProfileString(SectName,KeyName,PChar(DefaultStr),
; ; ; ; ; ; ; ; ; ; ; ; ; ; PChar(ResultString),100,Pchar(filename)
; ;
; ;if ResultString<>null then Edit6.text:=ResultString;
end;
在执行到GetPrivateProfileString时报错:
; ;accessviolation at address 77f87ffb in module 'ntdll.dll'
write of address d0404785
为何,我调用WritePrivateProfileString很正常,我的机器是nt 2000 server
谢谢