Solved

Setting DOS Environment Variables

Posted on 1997-03-25
2
159 Views
Last Modified: 2010-04-04
How do I set a DOS environment variable under Delphi 2.0.
I am currently using:-
      SetEnvironmentVariable('DFPATH', NewVarDirectory);

When I do I get an error Stating: "Incompatible Types 'String' and 'PCHAR'"
The variable NewVarDirectory simply holds the new directory name.

When I use
      SetEnvironmentVariable('DFPATH', 'F:\PRG\PROGRAMS');
there is no error generated.

Regards
Eric Kay
0
Comment
Question by:Eric Kay
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
mheacock earned 100 total points
ID: 1334959
your variable NewVarDirectory is a variable of type string.
All Win API functions require null-terminated strings
or PChars.

You'll need to convert the string to a PChar before you use it.
Or, if you are using D@, you can typecast the string.

There are conversion functions...StrPCopy and StrPas that
will do the trick.  See the help files.

If you want to typecast, do the following:

   SetEnvironmentVariable('DFPATH', PChar(NewVarDirectory));

0
 
LVL 3

Expert Comment

by:mheacock
ID: 1334960
D@ = Delphi 2

Forgot to let go of the shift key.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

17 Experts available now in Live!

Get 1:1 Help Now