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;