Solved

Problems calling a Windows API

Posted on 1998-08-24
3
142 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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