Solved

Problems calling a Windows API

Posted on 1998-08-24
3
141 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
Comment Utility
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
Comment Utility
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
Comment Utility
ArchIni:=TiniFille.Create( 'Monitor.ini' );
ArchIni.WriteString( 'Setup', 'Port', S );
.

ArchIni.Free;
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

12 Experts available now in Live!

Get 1:1 Help Now