cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
pbsdis
Level 6

Which one to use LOCALAPPDATA or shfolder.dll?

Hi,

In my IS MSI project, I need to resolve the current user's profile folder on Vista (and later), such as "C:\Users\user_id\".

I have been using MSI property 'USERPROFILE' and it works until today it failed in another Vista system - it's a big surprise to me though, I thought it should be consistent and persistent among all Vista systems.

Then I did a little bit more research and two of the tried alternatives are working for me:

1) MSI 'LOCALAPPDATA' property, it's simple to call (same as what I did to 'USERPROFILE'), just like
MsiGetProperty (ISMSI_HANDLE ,"LOCALAPPDATA",sDir,nResult);

2) ShFolder.dll, it's also simple enough

UseDLL("shfolder.dll");
SHFolder.SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, sDir);
UnUseDLL("shfolder.dll");



Can anybody elaborate the differences between the above two? Is one more reliable than the other?


Thanks,
PB
Labels (1)
0 Kudos
(1) Reply
pbsdis
Level 6

Correction:

MsiGetProperty (ISMSI_HANDLE ,"LOCALAPPDATA",sDir,nResult);

actually didn't work! I mistakenly used the same string variable (sDir) with the dll call and put this call after the dll call, so it still contains the value set from the dll call.

So the dll way is the only one I can use now, the only cost is that I have to include ShFolder.dll into my package.


Thanks,
PB
0 Kudos