Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DATE$ function
#20
I have QB64pe with admin and QB64 without and all I can say is that the following code works:

Code: (Select All)
Rem Admin.bas forces user to become admin.
Declare Dynamic Library "Shell32"
  Function IsUserAnAdmin& ()
  Sub ShellExecute Alias "ShellExecuteA" (ByVal hwnd As _Offset, lpOperation As String, lpFile As String, lpParameters As String, Byval lpDirectory As _Offset, Byval nShowCmd As Long)
End Declare
If IsUserAnAdmin = 0 Then
  Color 15
  Print "User is not admin. Press key:"
  While InKey$ = "": Wend
  Color 12
  Print "Force user to admin. Press key:"
  While InKey$ = "": Wend
  Call SelfElevate
End If
Color 14
Print "User should now be admin."
Color 15
Print "more:";
Do
  X$ = InKey$
  If Len(X$) Then
      Print
      If X$ = Chr$(27) Then
        Exit Do
      End If
      If IsUserAnAdmin Then
        Color 15
        Print "User is admin."
      Else
        Color 15
        Print "User is not admin."
      End If
      Color 15
      Print "more:";
  End If
Loop
Color 7
End

Sub SelfElevate
  ShellExecute 0, "runas" + Chr$(0), Command$(0) + Chr$(0), Command$ + Chr$(0), 0, 5
  System
End Sub
Reply


Messages In This Thread
DATE$ function - by eoredson - 10-04-2023, 05:31 AM
RE: DATE$ function - by mnrvovrfc - 10-04-2023, 07:11 AM
RE: DATE$ function - by SpriggsySpriggs - 10-04-2023, 11:19 AM
RE: DATE$ function - by SMcNeill - 10-04-2023, 11:27 AM
RE: DATE$ function - by TempodiBasic - 10-04-2023, 05:04 PM
RE: DATE$ function - by bplus - 10-04-2023, 05:34 PM
RE: DATE$ function - by RhoSigma - 10-04-2023, 06:23 PM
RE: DATE$ function - by Kernelpanic - 10-04-2023, 07:23 PM
RE: DATE$ function - by eoredson - 10-04-2023, 10:24 PM
RE: DATE$ function - by SMcNeill - 10-04-2023, 10:36 PM
RE: DATE$ function - by TerryRitchie - 10-04-2023, 10:51 PM
RE: DATE$ function - by eoredson - 10-04-2023, 10:52 PM
RE: DATE$ function - by eoredson - 10-04-2023, 11:10 PM
RE: DATE$ function - by eoredson - 10-05-2023, 01:49 AM
RE: DATE$ function - by SpriggsySpriggs - 10-05-2023, 11:11 AM
RE: DATE$ function - by eoredson - 10-06-2023, 12:57 AM
RE: DATE$ function - by SpriggsySpriggs - 10-06-2023, 02:10 AM
RE: DATE$ function - by eoredson - 10-06-2023, 02:22 AM
RE: DATE$ function - by SpriggsySpriggs - 10-06-2023, 02:58 AM
RE: DATE$ function - by eoredson - 10-06-2023, 04:33 AM
RE: DATE$ function - by eoredson - 10-06-2023, 03:43 AM
RE: DATE$ function - by SpriggsySpriggs - 10-06-2023, 12:26 PM
RE: DATE$ function - by eoredson - 10-07-2023, 05:01 AM
RE: DATE$ function - by SpriggsySpriggs - 10-07-2023, 01:49 PM
RE: DATE$ function - by mnrvovrfc - 10-07-2023, 05:03 AM
RE: DATE$ function - by eoredson - 10-08-2023, 10:21 PM
RE: DATE$ function - by eoredson - 10-11-2023, 04:25 AM
RE: DATE$ function - by SpriggsySpriggs - 10-12-2023, 03:14 AM
RE: DATE$ function - by eoredson - 10-12-2023, 11:25 PM
RE: DATE$ function - by SMcNeill - 10-12-2023, 11:37 PM
RE: DATE$ function - by eoredson - 10-13-2023, 12:46 AM
RE: DATE$ function - by eoredson - 10-19-2023, 01:35 AM
RE: DATE$ function - by eoredson - 10-21-2023, 03:15 AM
RE: DATE$ function - by SMcNeill - 10-21-2023, 04:17 AM
RE: DATE$ function - by eoredson - 10-21-2023, 05:52 AM
RE: DATE$ function - by SpriggsySpriggs - 10-21-2023, 04:07 AM
RE: DATE$ function - by SpriggsySpriggs - 10-21-2023, 06:50 AM
RE: DATE$ function - by eoredson - 10-23-2023, 01:29 AM
RE: DATE$ function - by SMcNeill - 10-23-2023, 01:40 AM
RE: DATE$ function - by SpriggsySpriggs - 10-23-2023, 11:55 AM
RE: DATE$ function - by eoredson - 10-24-2023, 01:49 AM
RE: DATE$ function - by SMcNeill - 10-24-2023, 02:32 AM
RE: DATE$ function - by SMcNeill - 10-24-2023, 02:36 AM
RE: DATE$ function - by eoredson - 10-25-2023, 02:40 AM
RE: DATE$ function - by mnrvovrfc - 10-25-2023, 03:43 AM
RE: DATE$ function - by eoredson - 10-25-2023, 04:00 AM
RE: DATE$ function - by SpriggsySpriggs - 10-25-2023, 12:13 PM
RE: DATE$ function - by eoredson - 10-25-2023, 11:53 PM
RE: DATE$ function - by Kernelpanic - 10-26-2023, 12:27 AM
RE: DATE$ function - by PhilOfPerth - 10-26-2023, 02:49 AM
RE: DATE$ function - by eoredson - 10-26-2023, 02:30 AM
RE: DATE$ function - by eoredson - 10-27-2023, 11:04 PM
RE: DATE$ function - by SMcNeill - 10-27-2023, 11:23 PM
RE: DATE$ function - by eoredson - 10-27-2023, 11:29 PM
RE: DATE$ function - by SMcNeill - 10-28-2023, 12:09 AM
RE: DATE$ function - by eoredson - 10-28-2023, 12:24 AM



Users browsing this thread: 20 Guest(s)