Solved

Win32 API

Posted on 2003-11-16
5
447 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now