Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Mar 29, 2020 1:09 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Windows User Access Control
PostPosted: Sat Aug 20, 2011 5:55 pm 
Offline

Joined: Mon Oct 03, 2005 4:30 pm
Posts: 54
Location: Auckland NZ
To test whether the program is being run as administrator you can attempt an operation that requires elevated privileges. I use:

Function UAC() As Boolean
#If TargetWin32 Then

Dim myBase As RegistryItem
Dim myParent As RegistryItem
Dim s As String = "HKEY_LOCAL_MACHINE\SOFTWARE"

' Check for 64bit OS
If InStr(0, SpecialFolder.Applications.AbsolutePath, "x86") > 0 Then s = s + "\Wow6432Node"

#pragma BreakOnExceptions Off
Try
myBase = New RegistryItem(s + "\UACTest", True) ' Attempt to add a new item
Catch RegistryAccessErrorException
Return False ' Didn't work, so not running elevated privileges
End Try

' Clean up so the test works next time
myParent = new RegistryItem(s)
Try
myParent.Delete("UACTest")
Catch RegistryAccessErrorException ' The first test would have worked if the key existed
Return False ' so this is a backup test
End Try
#endif

Return TrueEnd Function

When debugging I use the Run Paused option from the build menu then right click on the debug program and select runas administrator. This tests real world running and allows the IDE to run in normal mode.

You can set the runtime privilege on an application by right clicking the application and selecting properties. On the Compatibilty tab under Privilege Level tick the run as administrator checkbox. Be aware though that this property does not persist when the file is copied to a non-NTFS volume (cd, archive or FAT usb key).


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group