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. django 关于render的返回数据

    1,问题探讨 : 通过ajax 发送请求,接受render返回的数据.到底是什么样的类型呢? def text(request): # v = reverse("test") # ...

  2. 微信小程序开发--背景图显示

    这两天开发微信小程序,在设置背景图片时,发现在wxss里面设置 background-image:(url) 属性,不管是开发工具还是线上都无法显示.经过查资料发现,background-image ...

  3. 【转】C++11的enum class & enum struct和enum

    转自:https://blog.csdn.net/sanoseiichirou/article/details/50180533 C++标准文档——n2347(学习笔记) 链接:http://www. ...

  4. 如何从 Windows 虚拟机分离数据磁盘

    当不再需要附加到虚拟机的数据磁盘时,可以轻松地分离它. 这会从虚拟机中删除该磁盘,但不会从存储中删除它. Warning 如果用户分离磁盘,它不会自动删除. 如果订阅了高级存储,则将继续承担该磁盘的存 ...

  5. Linux命令(自学)

    1.立刻关机: shutdown -h now 2.立刻重启: shutdown -r now reboot 3.注销: logout 4.进入vi编辑器,写一个hello的java程序: vi he ...

  6. "添加"模态框中某些数据不被清空

    描述:一般情况下,“添加”的模态框弹出够,其中的输入框等为空,若是此中有某些数据是取自其他页面,不应被清空的,我们应当在html中添加以下内容.   解决方案:在form标签中添加“ preserve ...

  7. Web Services 根据wsdl生成代理类

    生成代理类步骤: 一:找到Visual Studio 的工具文件夹 二:用管理员方式打开本机工具命令提示 三:输入要执行的脚本 wsdl /language:C# /n:xxxx.HermesMobi ...

  8. [Redis_1] Redis 介绍 && 安装

    0. 说明 Redis 介绍 && 安装 1. Redis 介绍 2. Redis 安装(Windows 10) [2.1 解压 redis-2.2.2-win32-win64.rar ...

  9. ReportViewer 安装

    选择“工具”>“Nuget包管理器”>“程序包管理器控制台” 执行命令:Install-Package Microsoft.ReportingServices.ReportViewerCo ...

  10. NOIP2018考前抱佛脚——数据结构基础及STL实现

    目录 动态数组 栈 队列 优先队列 动态数组 srand(time(0)); std::vector<int> qwq; for(int i = 1;i <= 10;++i) qwq ...