VB6 CHECK is run as admin privilege

Source: Internet
Author: User

VB6 Code:

Private Declare Function isuseranadmin Lib "Shell32" Alias "#680" () as Integerprivate Sub Form_Load () If isuseranadmin () = 0 Thenmsgbox "not admin" elsemsgbox "admin" End IfEnd Sub

  

Get Windows OS version information:

Option explicitprivate Declare Function getversionex Lib "kernel32" Alias "GetVersionExA" _ (Lpversioninformation as OS  Versioninfo) as Longprivate Type osversioninfo osvsize as Long dwvermajor as long dwverminor as long dwBuildNumber as Long PlatformID as Long szcsdversion as String * 128End typeprivate Const Ver_platform_win32 s = 0Private Const VER_PLATFORM_WIN32_WINDOWS = 1Private Const VER_PLATFORM_WIN32_NT = 2 ' Returns the version of WINDOWS T Hat the user is Runningpublic Function getwindowsversion () as String Dim OSV as osVersionInfo osv. Osvsize = Len (OSV) If GetVersionEx (OSV) = 1 then Select case OSV. PlatformID case Ver_platform_win32s getwindowsversion = ' Win32s on Windows 3.1 ' case                    Ver_platform_win32_nt getwindowsversion = "Windows NT" Select Case osv.dwvermajor              Case 3 Getwindowsversion = "Windows NT 3.5"      Case 4 getwindowsversion = "Windows NT 4.0" Case 5 Select Case Osv.dwverminor case 0 getwindowsversion = "Windows 2                            Case 1 getwindowsversion = "Windows XP"                    Case 2 getwindowsversion = "Windows Server 2003" End Select                                Case 6, Select case, Osv.dwverminor case 0                                Getwindowsversion = "Windows vista/server" Case 1                                Getwindowsversion = "Windows 7/server R2" Case 2 Getwindowsversion = "Windows 8/server" Case 3 Getwindowsver sion = "Windows 8.1/servER R2 "End Select End Select Case ver_platform_win32_windows:                    Select Case Osv.dwverminor case 0 getwindowsversion = "Windows 95"                        Case getwindowsversion = "Windows Me" Case Else Getwindowsversion = "Windows 98" End Select End Select Else getwindowsversion = "    Unable to identify your version of Windows. " End IfEnd Function

  

Check OS byte + or 64:

private Declare Function GetProcAddress Lib "kernel32" _ (ByVal hmodule as Long, ByVal Lpprocname as String) as Longprivate Declare Function getmodulehandle Lib "kernel32" _ Alias "Getmodulehandlea" ( ByVal Lpmodulename as String) as Longprivate Declare Function getcurrentprocess Lib "kernel32" () as Longprivate Declare F Unction iswow64process Lib "kernel32" _ (ByVal hproc as Long, ByRef bwow64process as Boolean) as Longpublic Function is Host64bit () as a Boolean dim handle as a Long Dim is64bit as Boolean ' assume initially that this is not a WOW64 proc ESS is64bit = False ' then try to prove this wrong by attempting to load the ' iswow64process function Dynamicall Y handle = GetProcAddress (GetModuleHandle ("kernel32"), "iswow64process") ' The function exists, so call it If Han Dle <> 0 Then iswow64process getcurrentprocess (), is64bit End If ' Return ' value ishost64bit = is 64BitEnd Function 

  

VB6 CHECK is run as admin privilege

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.