InstallSheild 获取系统环境变量

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.

使用SHGetFolderPathA()

MSDN 

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

// Define Microsoft CSIDL constants 
//定义环境变量的ID
//参见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
//加载SHFolder.dll,这样就可以使用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.

//具体代码

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;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值