Installsheild: Get system environment variables

Source: Internet
Author: User

Copy and paste the following define statements at the beginning of your setup. RUL file. also, make sure you copy and paste the prototype for the shgetfolderpatha () Windows API. this Windows API retrieves the path
To the locations you want.

Use shgetfolderpatha ()

Msdn

SHGetKnownFolderPath http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188(v=vs.85).aspx

// Define Microsoft CSIDL constants 
// Define the ID of the Environment Variable
// See msdn knownfolderid
//http://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx
#define CSIDL_FAVORITES 0x0006 //%USERPROFILE%\Favorites
#define CSIDL_COMMON_FAVORITES 0x001f //%USERPROFILE%\Favorites
// Prototype SHGetFolderPathA in SHFolder.dll
// Load shfolder. dll so that you can use shgetfolderpatha ().
prototype NUMBER SHFolder.SHGetFolderPathA(HWND, NUMBER, NUMBER, NUMBER, BYREF STRING);

The following example code shows you how to call the above win API function.

// Code

function OnBegin()
number nFolder; // CSIDL value you want to use
string szPath; // Will contain path returned from API
number nResult; // Return value from API
begin
 try
 // Code to get user’s favorites directory
 nFolder=CSIDL_FAVORITES;
 szPath="";
 nResult=SHFolder.SHGetFolderPathA(NULL, nFolder, NULL, 0, szPath);
 if (nResult=0) then
  MessageBox("CSIDL_FAVORITES= "+szPath,0);
 else
  SprintfBox(SEVERE, "CSIDL_FAVORITES", "Failed(%d): %s", nResult, FormatMessage(nResult));
 endif;
 // Code to get common favorites directory
 nFolder=CSIDL_COMMON_FAVORITES;
 szPath="";
 nResult=SHFolder.SHGetFolderPathA(NULL, nFolder, NULL, 0, szPath);
 if (nResult=0) then  MessageBox("CSIDL_COMMON_FAVORITES= "+szPath,0);
 else
  SprintfBox(SEVERE, "CSIDL_COMMON_FAVORITES", "Failed(%d): %s", nResult, FormatMessage(nResult));
 endif;
 catch
  MessageBox("Unsupported OS.",0);
 endcatch;
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.