Archive: About Current User Permission


About Current User Permission
My setu package must write keys into the reg .

and i found that , when the current user of the os is not the administrator , i can't register my dll just via the regsvr32.exe ,

so i am asking that ,does there got a way to check is the current have the permission as administrator


Using forum search (link above) you can find few related threads and usefull links http://forums.winamp.com/search.php?...der=descending
Also plug-ins archive http://nsis.sourceforge.net/Category:Plugins and functions http://nsis.sourceforge.net/Category...ons_%26_Macros
And this is sample of .onInit function

!define REG_UNINST "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
Function .onInit

; Hand made admin permissions checkout
WriteRegStr HKLM "${REG_UNINST}" "TestString" "Some text"
IfErrors 0 cleanValue
MessageBox MB_OK "$(adminMsg)"
Abort
cleanValue:
DeleteRegValue HKLM "${REG_UNINST}" "TestString"
DeleteRegKey /ifempty HKLM "${REG_UNINST}"

!insertmacro MUI_LANGDLL_DISPLAY

FunctionEnd

Just a note: Hand made admin permissions check using WriteRegStr is no good idea. Besides the obvious problem caused by admin changed permissions I noticed some problems with Windows NT 4.0 especially when using the Uninstall key (as standard user there are "some" permissions but not all, maybe dependent on installed service pack).

If you want to do a hand made (light weight) check using the registry I suggest using HKEY_LOCAL_MACHINE/Software/Classes (e.g. with a self-generated GUID).