vb6 code:

Private Declare Function IsUserAnAdmin Lib "Shell32" Alias "#680" () As Integer

Private Sub Form_Load()

If IsUserAnAdmin() = 0 Then
MsgBox "Not admin"
Else
MsgBox "Admin"
End If end sub

  

get windows OS version information:

Option Explicit

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long Private Type OSVERSIONINFO
OSVSize As Long
dwVerMajor As Long
dwVerMinor As Long
dwBuildNumber As Long
PlatformID As Long
szCSDVersion As String * 128
End Type Private Const VER_PLATFORM_WIN32s = 0
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32_NT = 2 ' Returns the version of Windows that the user is running
Public 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 2000"
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 2008"
Case 1
GetWindowsVersion = "Windows 7/Server 2008 R2"
Case 2
GetWindowsVersion = "Windows 8/Server 2012"
Case 3
GetWindowsVersion = "Windows 8.1/Server 2012 R2"
End Select
End Select Case VER_PLATFORM_WIN32_WINDOWS:
Select Case osv.dwVerMinor
Case 0
GetWindowsVersion = "Windows 95"
Case 90
GetWindowsVersion = "Windows Me"
Case Else
GetWindowsVersion = "Windows 98"
End Select
End Select
Else
GetWindowsVersion = "Unable to identify your version of Windows."
End If
End Function

  

check OS byte 32 or 64:

Private Declare Function GetProcAddress Lib "kernel32" _
(ByVal hModule As Long, ByVal lpProcName As String) As Long Private Declare Function GetModuleHandle Lib "kernel32" _
Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function IsWow64Process Lib "kernel32" _
(ByVal hProc As Long, ByRef bWow64Process As Boolean) As Long Public Function IsHost64Bit() As Boolean
Dim handle As Long
Dim is64Bit As Boolean ' Assume initially that this is not a WOW64 process
is64Bit = False ' Then try to prove that wrong by attempting to load the
' IsWow64Process function dynamically
handle = GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process") ' The function exists, so call it
If handle <> 0 Then
IsWow64Process GetCurrentProcess(), is64Bit
End If ' Return the value
IsHost64Bit = is64Bit
End Function

  

shellexcute, application is run as admin

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As _
String, ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function IsUserAnAdmin Lib "Shell32" Alias "#680" () As Integer sample: ShellExecute 0, "runas", App.Path & "\1.exe", "/admin", vbNullString, 1

  

VB6 CHECK is run as admin privilege的更多相关文章

  1. Unable to extract 64-bitimage. Run Process Explorer from a writeable directory

    Unable to extract 64-bitimage. Run Process Explorer from a writeable directory When we run Process E ...

  2. java war run

    #!/bin/bashdate=`date +'%Y%m%d %T'`pid=`ps -ef |grep Credit | grep -v grep|awk '{print $2}'`damocles ...

  3. docker run option

    Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container Options: --add ...

  4. 解决:pipenv shell报错:AttributeError: 'module' object has no attribute 'run'

    利用pipenv shell切换到虚拟环境时,显示报错:AttributeError: 'module' object has no attribute 'run' 可以看到是d:\program\p ...

  5. kentico检查当前授权用户,是否为admin角色

    https://docs.kentico.com/k11/custom-development/user-internals-and-api/checking-permissions-using-th ...

  6. [转]python模块全面

    python模块 http://www.cnblogs.com/wupeiqi/articles/4963027.html 模块概念:用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编 ...

  7. zabbix入门

    第一章 监控知识基本概述 1.1 为什么要使用监控 1.对系统不间断实时监控2.实时反馈系统当前状态3.保证服务可靠性安全性4.保证业务持续稳定运行 1.2 如何进行监控,比如我们需要监控磁盘的使用率 ...

  8. BlackArch-Tools

    BlackArch-Tools 简介 安装在ArchLinux之上添加存储库从blackarch存储库安装工具替代安装方法BlackArch Linux Complete Tools List 简介 ...

  9. Python之路,Day6 - Python基础6

    本节大纲: 模块介绍 time &datetime模块 random os sys shutil json & picle shelve xml处理 yaml处理 configpars ...

随机推荐

  1. JS获取填报扩展单元格控件的值

    1. 问题描述 填报预览时,我们想获取到某个控件的值相对来说较容易.但如果控件是扩展的,就只能获取到第一个值,无法根据扩展一行行获取对应的值. 例:本意是想获取到袁成洁,结果还是获取到第一个单元格值孙 ...

  2. LeetCode题解之 3Sum

    1.题目描述 2.问题分析 使用hashtable 的方法做,解法不是最优的,思路简单直观. 3.代码 vector<vector<int>> threeSum(vector& ...

  3. Saltstack安装配置过程

    一.安装配置 1.服务器配置情况 三台服务器,均需要关闭iptables和selinux(否则salt执行指令无效) master: 192.168.60.139 centos slave: 192. ...

  4. Oracle EBS AP 应付核销到确定一行预付款

    -- purpose: 应付标准发票核销预付款发票中的一行 -- 12.2.6 环境 -- author:jenrry create_date: 2017-06-08 declare l_error_ ...

  5. Linux之因BASH造成的键盘错误和环境问题

    对于Linux我们习惯使用/bin/bash.并且大多数人操作在Centos系统上,但是仍有不少人在ubuntu上使用,两个操作系统大同小异.都是使用了Linux内核.接下来就来讲讲我使用过程中两个系 ...

  6. ansible 增加本机/etc/hosts 下hostsname 与IP

    --- - hosts: all vars: IP: "{{ ansible_eth0['ipv4']['address'] }}" tasks: - name: 将原有的host ...

  7. 第 15 章 位操作(binbit)

    /*------------------------------------ binbit.c -- 使用位操作显示二进制 ------------------------------------*/ ...

  8. gdb调试:

    1 简介      GDB(GNU Debugger)是GCC的调试工具.其功能强大,现描述如下:      GDB主要帮忙你完成下面四个方面的功能:      1.启动你的程序,可以按照你的自定义的 ...

  9. Phoenix安装配置

    下载Phoenix     在网站http://phoenix.apache.org/download.html找到对应HBase版本的安装程序,并下载安装包,解压安装程序到指定目录 [root@ha ...

  10. zabbix_windowsagent_cpu

    zabbix的WEB端--配置-模板--Template OS Windows--项目--创建项目 名称:UserPerfCountercpu 键值:UserPerfCountercpu 数据类型:数 ...