问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

VB中命令控件单击触发后怎么让它的效果是在一定的时间内关机

发布网友 发布时间:2022-05-11 01:38

我来回答

2个回答

热心网友 时间:2023-11-24 09:13

Private Sub Command1_Click()'定时关机
Shell "shutdown -s -t 30"
End Sub
Private Sub Form_Unload(Cancel As Integer) '关闭按钮,我假设你要弹出的窗口是FORM2
form2.Show
End Sub

热心网友 时间:2023-11-24 09:13

Attribute VB_Name = "WinClosemode"
Option Explicit
Private Const EWX_LogOff As Long = 0
Private Const EWX_SHUTDOWN As Long = 1
Private Const EWX_REBOOT As Long = 2
Private Const EWX_FORCE As Long = 4
Private Const EWX_POWEROFF As Long = 8
Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
Private Declare Function GetLastError Lib "kernel32" () As Long
Public Const mlngWindows95 = 0
Public Const mlngWindowsNT = 1
Public glngWhichWindows32 As Long
Private Declare Function GetVersion Lib "kernel32" () As Long
Private Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long
End Type
Private Type LUID_AND_ATTRIBUTES
TheLuid As LUID
Attributes As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End TypePrivate Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, _
ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Private Declare Sub SetLastError Lib "kernel32" (ByVal dwErrCode As Long)
Public Sys_NowTime As Date
Public Sys_StartTime As Date
Public Sys_CloseTime As Date
Public Sys_Tmptime As Date
Public Sys_Ding As Boolean'关机过程SUB
Function GetMytitle(index As Boolean) As String
GetMytitle = "定时关机" + CStr(App.Major) + "." + CStr(App.Minor) + IIf(index, IIf(Sys_Ding, "-定时中", ""), "")
End Function
Public Sub ShutDownWindowsNT()
Const TOKEN_ADJUST_PRIVILEGES = &H20
Const TOKEN_QUERY = &H8
Const SE_PRIVILEGE_ENABLED = &H2
Dim hdlProcessHandle As Long
Dim hdlTokenHandle As Long
Dim tmpLuid As LUID
Dim tkp As TOKEN_PRIVILEGES
Dim tkpNewButIgnored As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long
SetLastError 0
hdlProcessHandle = GetCurrentProcess()
OpenProcessToken hdlProcessHandle, (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY), hdlTokenHandle
LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid
tkp.PrivilegeCount = 1
tkp.TheLuid = tmpLuid
tkp.Attributes = SE_PRIVILEGE_ENABLED
AdjustTokenPrivileges hdlTokenHandle, False, tkp, Len(tkpNewButIgnored), tkpNewButIgnored, lBufferNeeded
End Sub
Public Sub ShutDownWindows9X()
ExitWindowsEx (EWX_SHUTDOWN), &HFFFF
End SubPublic Sub CloseWindowsNow()
If glngWhichWindows32 = mlngWindowsNT Then
ShutDownWindowsNT
End If
ShutDownWindows9X
End
End SubFunction SetWindowsVer() As Boolean
Dim lngVersion As Long
lngVersion = GetVersion()
If ((lngVersion And &H80000000) = 0) Then
glngWhichWindows32 = mlngWindowsNT
Else
glngWhichWindows32 = mlngWindows95
End If
End Function按钮调用:CloseWindowsNow()
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
广东省考考哪3科 六个月宝宝缺铁吃什么好 疯狂动物园 大猩猩栖息地升级技巧 疯狂动物园怎么办boss任务 boss任务过法 疯狂动物园怎么驯服火山猩猩 疯狂动物园驯服火山猩猩 疯狂动物园火山猩猩 在陌生的城市如何辨别东南西北? 女羊男虎千万别在一起 女羊男虎婚配好不好 属羊女与属虎男婚姻能否长久 属羊女的和什么属相最配 word横线上打字不破坏横线 VB的命令按钮控件数组在哪里 我在excel2003中录制了宏,然后添加了命令控件,为什么控件里面无法指定宏?在这种情况下要怎么指定宏呢? 如何添加VB命令控件 求《快穿之打脸的正确方式》完结+番外TXT百度云 西安秦汉新城哪可以交交强险? 简述化学知识在国防教育中的应用及意义 2016年天津高考理综试卷难不难,难度系数解读答案点评解析 《新东方2016年高考试题解析视频(超清视频)百度网盘》epub下载在线阅读全文,求百度网盘云资源 2016年全国高考化学试题有几套 请问:丹阳有什么地方可以踏青,找到春天的感觉,放松一下去.想 你去过镇江吗?什么季节去最合适? 丹阳有哪些好玩的地方? 丹阳市九里风景区特产有哪些? 广州特产那里有 女23岁 月经中期出血 请问我月经前10几天有点出血。然后可能 什么是医美护肤品啊?有推荐的牌子吗 心生美医美品牌属于哪个公司? 梦到陌生人为救自己而死预兆什么呢? 梦见我掉水里了.有2个人因为救我死了.可是我不知道是谁救我. 用VBA命令控件指定条件打印 请问excel的窗体按钮跟控件工具箱的命令按钮有什么区别?怎么使用 在10版excel的命令栏中添加自己设定的控件按钮 excel表中“控件工具箱”里的“命令按扭”如何指定宏 命令行怎么开启activex控件 access2003中窗体部分在工具箱里点击"命令按钮"控件后 如何弹出"命令向导按钮"对话框? EXCEL的控件命令按扭怎么用,代码如何写啊 VFP中同时设置所有控件属性的命令是什么?急 怎样取消苹果mac mini上的客户登录? 女人才45岁为什么会掉头发 斗鱼寅子有孩子吗 京东里如果赠品被买家用过了,退货的时候商家要求赔钱,该怎么办,要不要赔钱呢? 用京东白条分期购物发生退货,怎么处理? 医疗行业如何做好竞价推广数据分析 我是歌手第5季有哪些歌手 张碧晨在我想和你唱里出现在第几季 有什么考研作文有用的软件 考研英语APP哪个好? 研究生英语写作建议掌握的工具软件有哪些 考研英语作文是怎么评分的,网上能查到一些,有更专业的老师给解答一下吗?