Professor
asked on
Win32 API
i need to use the following win32 api functions in delphi:
GetPrivateProfileSection,
GetPrivateProfileString,
WritePrivateProfileSection and
WritePrivateProfileString
for reading from and writing to ini files.
I just don't seem to be able to figure out how to actually make delphi use the functions...
Can someone help please?
Thanks in advance
GetPrivateProfileSection,
GetPrivateProfileString,
WritePrivateProfileSection
WritePrivateProfileString
for reading from and writing to ini files.
I just don't seem to be able to figure out how to actually make delphi use the functions...
Can someone help please?
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Easy...
var
TheValue: Array[0..MAX_PATH] of Char;
begin
// Get some file path from 'TheIniFile.ini' in your applications directory.
GetPrivateProfileString('P aths', 'FilePath1', nil, @TheValue, MAX_PATH, PChar(ExtractFilePath(Para mStr(0))+' TheIniFile .ini'));
// Write your own filepath to FilePath2 value
WritePrivateProfileString( 'Paths', 'FilePath2', PChar(ParamStr(0)), PChar(ExtractFilePath(Para mStr(0))+' TheIniFile .ini'));
end;
I wrote this code from memory so if something is wrong don't hesitate to tell me (Should work perfectly though)
var
TheValue: Array[0..MAX_PATH] of Char;
begin
// Get some file path from 'TheIniFile.ini' in your applications directory.
GetPrivateProfileString('P
// Write your own filepath to FilePath2 value
WritePrivateProfileString(
end;
I wrote this code from memory so if something is wrong don't hesitate to tell me (Should work perfectly though)
ASKER
@gmayo:
This is about the basics of what I'm trying to do:
const cfgFile = 'ext-pisg.conf';
procedure tConfig.Load;
var cfgIni : TIniFile;
str : TStrings;
begin
cfgIni.Create(cfgFile);
MessageDlg(cfgIni.FileName , mtInformation,
[mbOk], 0);
end;
but whenever I call the cfgIni.Create(cfgFile); i get a Stack Overflow. Do you know why this happens?
This is about the basics of what I'm trying to do:
const cfgFile = 'ext-pisg.conf';
procedure tConfig.Load;
var cfgIni : TIniFile;
str : TStrings;
begin
cfgIni.Create(cfgFile);
MessageDlg(cfgIni.FileName
[mbOk], 0);
end;
but whenever I call the cfgIni.Create(cfgFile); i get a Stack Overflow. Do you know why this happens?
You're creating it wrong. Use:
cfgIni := TIniFile.Create(cfgFile);
instead of:
cfgIni.Create(cfgFile);
That should work!
Geoff M.
cfgIni := TIniFile.Create(cfgFile);
instead of:
cfgIni.Create(cfgFile);
That should work!
Geoff M.
ASKER