InstallSheild 获取系统环境变量,如Desktop路径等

  使用FOLDER_DESKTOP变量获取的桌面路径可能为:C:\Users\Public\Desktop

  而不是C:\Users\用户\Desktop

  

  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.  

setup.rul  Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
// Define Microsoft CSIDL constants
//定义环境变量的ID,更详细参见shlobj.h
//参见msdn KNOWNFOLDERID
//http://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx
#define  CSIDL_DESKTOP                   0x0000         // <desktop>
#define  CSIDL_INTERNET                  0x0001         // Internet Explorer (icon on desktop)
#define  CSIDL_PROGRAMS                  0x0002         // Start Menu\Programs
#define  CSIDL_CONTROLS                  0x0003         // My Computer\Control Panel
#define  CSIDL_PRINTERS                  0x0004         // My Computer\Printers
#define  CSIDL_PERSONAL                  0x0005         // My Documents
#define  CSIDL_FAVORITES                 0x0006         // <user name>\Favorites
#define  CSIDL_STARTUP                   0x0007         // Start Menu\Programs\Startup
#define  CSIDL_RECENT                    0x0008         // <user name>\Recent
#define  CSIDL_SENDTO                    0x0009         // <user name>\SendTo
#define  CSIDL_BITBUCKET                 0x000a         // <desktop>\Recycle Bin
#define  CSIDL_STARTMENU                 0x000b         // <user name>\Start Menu
#define  CSIDL_MYDOCUMENTS               CSIDL_PERSONAL  //  Personal was just a silly name for My Documents
#define  CSIDL_MYMUSIC                   0x000d         // "My Music" folder
#define  CSIDL_MYVIDEO                   0x000e         // "My Videos" folder
#define  CSIDL_DESKTOPDIRECTORY          0x0010         // <user name>\Desktop
#define  CSIDL_DRIVES                    0x0011         // My Computer
#define  CSIDL_NETWORK                   0x0012         // Network Neighborhood (My Network Places)
#define  CSIDL_NETHOOD                   0x0013         // <user name>\nethood
#define  CSIDL_FONTS                     0x0014         // windows\fonts
#define  CSIDL_TEMPLATES                 0x0015
#define  CSIDL_COMMON_STARTMENU          0x0016         // All Users\Start Menu
#define  CSIDL_COMMON_PROGRAMS           0X0017         // All Users\Start Menu\Programs
#define  CSIDL_COMMON_STARTUP            0x0018         // All Users\Startup
#define  CSIDL_COMMON_DESKTOPDIRECTORY   0x0019         // All Users\Desktop
#define  CSIDL_APPDATA                   0x001a         // <user name>\Application Data
#define  CSIDL_PRINTHOOD                 0x001b         // <user name>\PrintHood
// 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.
setup.rul  Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
function OnBegin()
    number nFolderCSIDL;       // CSIDL value you want to use
    string szPath;                 // Will contain path returned from API
    number nResult;            // Return value from API
begin
    
try
        szPath = 
"" ;
        nFolderCSIDL = CSIDL_DESKTOP;
        nResult = SHFolder.SHGetFolderPathA(
NULL , nFolder,  NULL 0 , szPath);
    
if  (nResult =  0 ) then
        MessageBox(
"CSIDL_DESKTOP = "  + szPath,  0 );
    
else
        SprintfBox(SEVERE, 
"CSIDL_DESKTOP" "Failed(%d): %s" , nResult, FormatMessage(nResult));
    endif;
end;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值