NSIS installer and Vista

Miscellaneous Forums/General Discussion/NSIS installer and Vista

If you use NSIS and want to ensure you're game is installed to the correct directory for Vista compatibility you can use the following NSIS function.

Function GetCommonAppData
  Push $1
  Push $2
  Push $3
  Push $4  
 
  StrCpy $1 ""
  StrCpy $2 "0x0023" # CSIDL_COMMON_APPDATA  (0x0023)
  StrCpy $3 ""
  StrCpy $4 ""
 
  System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r1, i r2, i r3) i .r4'
 
  Pop $4
  Pop $3
  Pop $2
  Exch $1
FunctionEnd


Use it like this :
Section -Files
	Call GetCommonAppData
	Pop $0
	SetOutPath "$0\Harmony\html"
	FILE /r "G:\Application Development\Harmony_ATL\html\*.*"
	SetOutPath "$0\Harmony"
	FILE "G:\Application Development\Harmony_ATL\Harmony.exe"
	FILE "G:\Application Development\Harmony_ATL\Launcher.exe"
SectionEnd


Don't say I didn't tell ya.

thx. bookmarked.

So does it make the folder with the correct permissions for modifying files? e,g, profile files by current user, and global settings/high scores files by all users?

Actually I'd rather do this in code as there is no guarantee that portals will make their installers put stuff in the correct place...

I've been getting my game ready to go on portals for the last couple of weeks, and have been told specifically to use CSIDL_LOCAL_APPDATA.

Tried and tested, this creates the correct permissions and can be read and written by any account on any WinOS - even UAC. Hey download Harmony in a UAC account and then run it from Admin or another UAC - it works (and there is a load of disk IO going on)!

http://www.pjio.com/temp/Harmony_setup.exe

GfK: Hmm but Common AppData is for shared files like options/highscores. If you put them in local appdata they wouldn't be global right?

Right.

And you've been told to use the Local one. Weird. Even if you put the players profile in there, how would you display a list of available profiles, you couldn't (as they be in other users' private folders. The profiles all need to be in a common location too...