Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting DOS Environment Variables

Posted on 1997-03-25
2
Medium Priority
?
183 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 300 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline
Suggested Courses

783 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