?
Solved

Win32 API

Posted on 2003-11-16
5
Medium Priority
?
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

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

Accepted Solution

by:
gmayo earned 400 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

762 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