[Go] Get common system environment variables with getenvironmentvariable

Source: Internet
Author: User

Previously used GetWindowsDirectory, GetSystemDirectory, GetTempPath and other functions to obtain the system commonly used folders;
Also used shgetspecialfolderlocation, shgetpathfromidlist function to obtain more common paths;
But this is not as fast as getting system variables with getenvironmentvariable.

For example,%WINDIR% is a system variable that represents the system directory,which can be obtained:varstring;   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% {Current User root directory-C:}%USERPROFILE% {Current User directory-C:\Documents and Settings\wy}%homepath% {Current user path-\documents and Settings\wy}%TMP% {Current User temp folder-c:\docume~1\wy\locals~1\temp}%temp% {Current User temp folder-c:\docume~1\wy\locals~1\temp}%appdata% {Current User Data folder-C:\Documents and Settings\wy\application%PROGRAMFILES% {Program default installation directory-C:\Program Files}%commonprogramfiles% {File Universal directory-C:\Program Files\Common Files}%USERNAME% {Current user name-WY}%allusersprofile% {All user files directory-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% {The domain containing the user account-ibm-b63851e95c9}%comspec% {C:\WINDOWS\system32\cmd.exe}%pathext% {Execute file type-. COM;. EXE;. BAT;. CMD;. VBS;. VBE;. JS;. JSE;. WSF;. WSH;. PYO;. PYc;. py;. Pyw%PATH% {Search Path}
   
    
   

In addition, you can take advantage of: To the upper-level directory, such as:
var string;   begin S: = Getcurrentdir; ShowMessage (s); {C:\Documents and settings\wy\my Documents\rad studio\projects}  Setcurrentdir ('.. ')   );   s: = Getcurrentdir; ShowMessage (s); {C:\Documents and settings\wy\my Documents\rad Studio}  Setcurrentdir ('.. \..‘   );   s: = Getcurrentdir; ShowMessage (s); {C:\Documents and Settings\wy}  End;

[Go] Get common system environment variables with getenvironmentvariable

Related Article

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.