Use getenvironmentvariable to obtain common system environment variables

Source: Internet
Author: User
Previously, we used functions such as getwindowsdirectory, getsystemdirectory, and gettemppath to obtain common system folders;

You have also used the shgetspecialfolderlocation and shgetpathfromidlist functions to obtain more common paths;

However, it is better to use getenvironmentvariable to obtain the system variable token quickly.

 
// For example, % WINDIR % indicates the system variable of the system directory. You can obtain: var S: string; begin S: = getenvironmentvariable ('windir'); showmessage (s ); {C: \ WINDOWS} end;

  

% WINDIR % {system directory-C: \ WINDOWS} % SystemRoot % {system directory-C: \ WINDOWS} % systemdrive % {system root directory-C :} % homedrive % {root directory of the current user-C :}% USERPROFILE % {current user directory-C: \ Documents ents and Settings \ WY} % homepath % {current user path-\ Documents ents and Settings \ WY} % TMP % {current user Temporary Folder-c: \ temporary E ~ 1 \ WY \ locals ~ 1 \ Temp} % Temp % {temporary folder of the current user-c: \ temporary E ~ 1 \ WY \ locals ~ 1 \ Temp} % appdata % {current user data folder-c: \ Documents ents and Settings \ WY \ Application Data} % ProgramFiles % { Program Default installation directory-c: \ Program Files} % commonprogramfiles % {common file directory-C: \ Program Files \ common files} % username % {current user name-Wy} % allusersprofile % {all user file directories-C: \ Documents and Settings \ All Users} % OS % {operating system name-windows_nt} % computername % {computer name-IBM-B63851E95C9} % number_of_processors % {Number of processors-1} % processor_architecture % {processor chip architecture-x86} % processor_level % {Processor Model-6} % processor_revision % {processor revision number-0905} % userdomain % {domain containing user account-IBM-B63851E95C9} % comspec % {C: \ windows \ system32 \ cmd.exe} % pathext % {execution file type -. com ;. EXE ;. BAT ;. CMD ;. vbs ;. VBE ;. JS ;. JSE ;. WSF ;. wsh ;. pyo ;. pyC ;. PY ;. pyw} % PATH % {search path}
  
   
 

In addition, you can use... to go to the upper directory, such:

 var S: string; begin S: = getcurrentdir; showmessage (s); {C: \ Documents ents and Settings \ WY \ My Documents ents \ rad studio \ projects} setcurrentdir ('.. '); s: = getcurrentdir; showmessage (s); {C: \ Documents and Settings \ WY \ My Documents ents \ rad studio} setcurrentdir ('.. \.. '); s: = getcurrentdir; showmessage (s); {C: \ Documents ents and Settings \ WY} end;

   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.