User mode installing??
- DoubleDutch
- Addict

- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
User mode installing??
When in user mode, where can you install programs to? Whats the official API call to find this location (if it exists!)...
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
- DoubleDutch
- Addict

- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
I also need to know how to detect if the user has administrative rights or none at all.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
For admin right :
Code: Select all
ProcedureDLL IsUserAnAdmin()
; Changed in 1.2 because don't work with Impersonate : This version Works great
ret = openSCmanager_(#Null,#Null,#SC_MANAGER_ALL_ACCESS)
If ret
closeServiceHandle_(ret)
EndIf
If ret>0 : ret =1 : EndIf
ProcedureReturn ret
EndProcedureFor install directory use 38 as value :
Code: Select all
ProcedureDLL.s GetSpecialFolderLocation(Valeur.l)
If SHGetSpecialFolderLocation_(0, Valeur, @Dossier_ID) = 0
SpecialFolderLocation.s = Space(#MAX_PATH)
SHGetPathFromIDList_(Dossier_ID, @SpecialFolderLocation)
If SpecialFolderLocation
If Right(SpecialFolderLocation, 1) <> "\"
SpecialFolderLocation + "\"
EndIf
EndIf
EndIf
ProcedureReturn SpecialFolderLocation.s
EndProcedure - DoubleDutch
- Addict

- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Thanks, I will use this.For admin right :
etc...
I figured this one out by looking at what happens to 'google earth'. But thanks all the same.For install directory use 38 as value :
etc...
For those others reading this who also have a similar problem, don't forget to move over to CURRENT_USER in registry settings rather than CURRENT_MACHINE (if user mode detected).
Lots of programs have the the problem where thay will say "no access rights" when trying to install (including PureBasic!). The above info provided by Droopy will help you bypass these errors completely.
-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
- DoubleDutch
- Addict

- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Droopy, #38 ALWAYS returns Program Files - if in user or admin mode...
If in user mode you should use the program data path or similar as that is useable, it doesn't look right however - i'd rather use the dir above the program data path - google earth uses this.
-Anthony
If in user mode you should use the program data path or similar as that is useable, it doesn't look right however - i'd rather use the dir above the program data path - google earth uses this.
-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
For Windows 2000 and higher:
Code: Select all
Debug IsUserAnAdmin_() ; 1=Yes, 0=NoI compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- tinman
- PureBasic Expert

- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
Wouldn't it be better to get the program files directory, then use some windows API function to see whether you can write there rather than checking whether a user is an admin or not?DoubleDutch wrote:Thanks, I will use this. :) At present I'm just using a hack that tries to create a file where it shouldn't. An error means its user mode. ;)For admin right :
etc...
This page seems to explain how to do it (in C) but I've not tried it: http://www.devx.com/cplus/Article/16711/1954?pf=true
By default XP comes configured with 3 user groups - administrators, power users and users. Administrators and power user can both install software on a per machine basis, but a power user would not show up as an administrator and probably wouldn't have full control over the service manager.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
