Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Setting DOS Environment Variables

Posted on 1997-03-25
2
Medium Priority
?
182 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
[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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

721 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