Solved

Problems calling a Windows API

Posted on 1998-08-24
3
143 Views
Last Modified: 2010-04-04
Hi.... I'm trying to call a Windows API this way:

WritePrivateProfileString('Setup', 'Port', @S, 'Monitor.ini' );

where S is a string[1]. Obviously, this call is bad because it doesn't work. How can I do it to pass a string variable as parameter? If I use only S, compiler doesn't compile the code. Please Help!!!

Thanks in advance,
Jaime
0
Comment
Question by:skel
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 50 total points
ID: 1337606
You need to write:
WritePrivateProfileString('Setup', 'Port', pChar(S), 'Monitor.ini' );

See example on:
http://x12.dejanews.com/getdoc.xp?AN=322713398&CONTEXT=904027635.935591984&hitnum=14
0
 

Author Comment

by:skel
ID: 1337607
I looked at the example and I realized that I could use TIniFile component to access the Ini File. I used:

var ArchIni : TIniFile;

and then

ArchIni.Create( 'Monitor.ini' );
ArchIni.WriteString( 'Setup', 'Port', S );

When I run this code, compiler sends the warning:
'Variable ArchIni might not have been initialized'
and when I close the program, I got an exception Error on the application.
How can I solve it?

Thanks again in advance
Jaime

0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1337608
ArchIni:=TiniFille.Create( 'Monitor.ini' );
ArchIni.WriteString( 'Setup', 'Port', S );
.

ArchIni.Free;
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

14 Experts available now in Live!

Get 1:1 Help Now