Solved

Win32 API

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi component that can load a DLL in design time? 8 93
Printing problem 2 111
Correct Component for Shopping Cart. 2 121
Performance of SQL statement 37 137
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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