Advertisement
Jailout2000

Realbasic / Xojo Studio Windows User Access Control (UAC)

Nov 5th, 2013
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.12 KB | None | 0 0
  1. Sub Action()
  2.  
  3.   '// This code will launch said application in administrative mode, and depending
  4.   '// on the user's UAC mode, may or may not show a UAC dialog
  5.  
  6.   Declare Function ShellExecuteA Lib "Shell32" (hwnd As Integer, lpOperation As CString, lpFile As CString, _
  7.   lpParameters As CString, lpDirectory As CString, nShowCmd As Integer) As Integer
  8.  
  9.   Const SW_HIDE = 0
  10.   Const SW_MAXIMIZE = 3
  11.   Const SW_MINIMIZE = 6
  12.   Const SW_RESTORE = 9
  13.   Const SW_SHOW = 5
  14.   Const SW_SHOWDEFAULT = 15
  15.   Const SW_SHOWMAXIMIZED = 3
  16.   Const SW_SHOWMINIMIZED = 2
  17.   Const SW_SHOWMINNOACTIVE = 7
  18.   Const SW_SHOWNA = 8
  19.   Const SW_SHOWNOACTIVATE = 4
  20.   Const SW_SHOWNORMAL = 1
  21.  
  22.   Call ShellExecuteA(Self.Handle, "runas", "C:\Windows\Notepad.exe", "C:\Windows\System32\drivers\etc\hosts", "", SW_SHOWNORMAL)
  23.  
  24. End Sub
  25. Sub Open()
  26.  
  27.   '// This code will create a UAC icon on this PushButton
  28.  
  29.   Declare Function SendMessageA Lib "User32" (hWnd As Integer, Msg As Integer, wParam As Integer, lParam As Integer) As Integer
  30.  
  31.   Const BCM_SETSHIELD = &h0000160C
  32.  
  33.   Call SendMessageA(Me.Handle, BCM_SETSHIELD, 0, 1)
  34.  
  35. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement