VB6 CHECK is run as admin privilege
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的更多相关文章
- 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 ...
- java war run
#!/bin/bashdate=`date +'%Y%m%d %T'`pid=`ps -ef |grep Credit | grep -v grep|awk '{print $2}'`damocles ...
- docker run option
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container Options: --add ...
- 解决:pipenv shell报错:AttributeError: 'module' object has no attribute 'run'
利用pipenv shell切换到虚拟环境时,显示报错:AttributeError: 'module' object has no attribute 'run' 可以看到是d:\program\p ...
- kentico检查当前授权用户,是否为admin角色
https://docs.kentico.com/k11/custom-development/user-internals-and-api/checking-permissions-using-th ...
- [转]python模块全面
python模块 http://www.cnblogs.com/wupeiqi/articles/4963027.html 模块概念:用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编 ...
- zabbix入门
第一章 监控知识基本概述 1.1 为什么要使用监控 1.对系统不间断实时监控2.实时反馈系统当前状态3.保证服务可靠性安全性4.保证业务持续稳定运行 1.2 如何进行监控,比如我们需要监控磁盘的使用率 ...
- BlackArch-Tools
BlackArch-Tools 简介 安装在ArchLinux之上添加存储库从blackarch存储库安装工具替代安装方法BlackArch Linux Complete Tools List 简介 ...
- Python之路,Day6 - Python基础6
本节大纲: 模块介绍 time &datetime模块 random os sys shutil json & picle shelve xml处理 yaml处理 configpars ...
随机推荐
- docker 开发常用命令总结
Docker 常用命令总结,镜像下载,到docker容器创建,常用docker命令的 增删查 1.镜像下载,从hub.docker.com中下载最新版本的postgres docker pull po ...
- Memcached+WebApi记录
一.安装Memcached Memcached1.2.6 http://files.cnblogs.com/files/jasonduan/11465401756756.zip Memcached.C ...
- 《Spring实战》第4章--面向切面的Spring--处理通知中的参数(经验总结)
今天学习<Spring实战>第4章<面向切面的Spring>,根据4.3.3小节写出如下切面类: package proxy; import java.util.HashMap ...
- Python 自定义线程池
"""思路1,将任务放在队列 1)创建队列:(初始化) 2)设置大小,线程池的最大容量 3)真实创建的线程 列表 4)空闲的线程数量 2,着手开始处理任务 1)创建线程 ...
- localStorage/cookie 用法分析与简单封装
本地存储是HTML5中提出来的概念,分localStorage和sessionStorage.通过本地存储,web应用程序能够在用户浏览器中对数据进行本地的存储.与 cookie 不同,存储限制要大得 ...
- 【Kibana】Kibana入门教程
一.Kibana简介及下载安装 Kibana是专门用来为ElasticSearch设计开发的,可以提供数据查询,数据可视化等功能. 下载地址为:https://www.elastic.co/downl ...
- NETBEAN 启动报错 CANNOT LOCATE JAVA INSTALLATION IN SPECIFIED JDKHOME的解决办法
打开 NetBeans 安装目录下的\etc目录,查找报错信息中的jdk字符串,修改netbeans.conf文件即可
- 前端开发使用Photoshop切图详细步骤
切图的主要目的是从设计师提供的psd中获取网页制作所要的资源 一.界面设置 1. 新建文件,调整界面大小,背景设置为透明 2. 自动选择,把组切换为图层 3. 添加窗口内容,一共四项:图层.历史纪录. ...
- 使用MonkeyTest对Android客户端进行压力测试
目录 monkey命令简介 monkey命令参数说明 自动化实例 如何通过日志定位问题 1.monkey命令简介 Monkey是Android中的一个命令行工具,可以运行在模拟器里或实际设备中.它 ...
- elasticsearch DSL查询
总结一个DSL的用法吧,语法网上查去,只记录一点心得,也是研究了半天,太麻烦了 先附上python代码 #!/usr/bin/env python # _*_ coding:utf-8 _*_ fro ...