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 ...
随机推荐
- Dynamics 365Online 通过插件中的retrievemultiple消息来过滤产品视图
本篇中要讲的是对产品视图基于某个条件进行过滤显示,而手段就是通过插件中的retrievemultiple消息,可能很多人都写过对它都不陌生. 先来看张插件注册的截图,插件的message是retrie ...
- [Android] ACTION_GET_CONTENT与ACTION_PICK的区别
参考:AndroidSDK/docs/reference/android/content/Intent 看到相关代码,对这两个参数的区别有点搞不清. 原文地址请保留http://www.cnblogs ...
- windows下安装并启动hadoop2.7.2
64位windows安装hadoop没必要倒腾Cygwin,直接解压官网下载hadoop安装包到本地->最小化配置4个基本文件->执行1条启动命令->完事.一个前提是你的电脑上已经安 ...
- 基于MD5的增强型摘要算法
message-digest algorithm 5(信息-摘要算法),md5的长度,默认为128bit,也就是128个0和1的二进制串.但是,这样表达是很不友好的,所以将二进制转成了16进制,每4个 ...
- 记一款bug管理系统(bugdone.cn)的开发过程(3) - 永久免费化
BugDone永久免费了! BugDone(bug管理工具)已经发布有一阵子了,自发布以来注册用户量.项目创建量稳步提升,并且得到了很多用户的好评. 在开发BugDone工具之前,我们团队也曾为找不到 ...
- Oracle EBS OPM 发放生产批
--发放生产批 --created by jenrry DECLARE x_return_status VARCHAR2 (1); l_exception_material_tbl gme_commo ...
- Oracle EBS INV 更新状态
使用API改变现有物料状态,改成如下:On-Hand, Subinventory, Locator, Lot & Serial.参数使用如下:H, O, S, Z, L.对应如下: 'H' - ...
- 网工最实用最常用的网络命令之一——Ping 命令详解(一)
Ping是Windows.Unix和Linux系统下的一个命令.ping也属于一个通信协议,是TCP/IP协议的一部分.利用“ping”命令可以检查网络是否连通,可以很好地帮助我们分析和判定网络故障. ...
- 《SQL Server 2008从入门到精通》--20180724
目录 1.事务 1.1.事务的ACID属性 1.2.事务分类 1.2.1.系统提供的事务 1.2.2.用户自定义的事务 1.3.管理事务 1.3.1.SAVE TRANSACTION 1.3.2.@@ ...
- Java语言的主要特点
Java语言有很多的优点,可靠.安全.编译和解释型语言.分布式.多线程.完全面向对象.与平台无关性等等. 与平台无关性 Java语言最大的优势在于与平台无关性,也就是可以跨平台使用. 绝大多数的编程语 ...