使用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; |