?
Solved

Problems calling a Windows API

Posted on 1998-08-24
3
Medium Priority
?
147 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
[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
3 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 150 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

Industry Leaders: 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

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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 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