Solved

Win32 API

Posted on 2003-11-16
5
450 Views
Last Modified: 2010-04-03
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
0
Comment
Question by:Professor
  • 2
  • 2
5 Comments
 

Author Comment

by:Professor
ID: 9759337
yeah ;) *lol*
0
 
LVL 8

Accepted Solution

by:
gmayo earned 100 total points
ID: 9759342
You might want to look at TIniFile which provides a wrapper around the Win32 SDK, ie it calls most of the functions you mention. It is quite easy to use. Let me know if you need more help.

Geoff M.
0
 

Expert Comment

by:unfunf
ID: 9759362
Easy...

var
    TheValue: Array[0..MAX_PATH] of Char;
begin
    // Get some file path from 'TheIniFile.ini' in your applications directory.
    GetPrivateProfileString('Paths', 'FilePath1', nil, @TheValue, MAX_PATH, PChar(ExtractFilePath(ParamStr(0))+'TheIniFile.ini'));
    // Write your own filepath to FilePath2 value
    WritePrivateProfileString('Paths', 'FilePath2', PChar(ParamStr(0)), PChar(ExtractFilePath(ParamStr(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)
0
 

Author Comment

by:Professor
ID: 9759474
@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?
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9759661
You're creating it wrong. Use:
 cfgIni := TIniFile.Create(cfgFile);
instead of:
 cfgIni.Create(cfgFile);

That should work!

Geoff M.
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Syntax Check Delphi Seattle IOS app without MAC ? 1 98
SUM 2 INTEGER ARRAYS INTO 1 10 101
Delphi: making a BW image transparent 10 41
DBCtrlGrid, Delphi, Scroll 8 15
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question