发布网友 发布时间:2024-09-29 04:36
共3个回答
热心网友 时间:2024-10-04 17:45
需要修改扩展名的. 不需要弄到Vb程序里! 把扩展名修改成*.vbs,双击就可以运行了! 不信你自己试试!
热心网友 时间:2024-10-04 17:42
比方说要对方输入我是猪否则关机.就是一个判断语句.或者是循环,不满足条件就反复循环而已。
就是
if textbox1.text="我是猪"
exit
else
关机
热心网友 时间:2024-10-04 17:44
啊,这样不太好吧。。。。 强行关机: 调用SHUTDOWN, shutdown -s -t 0 复杂的: API Private 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 Const TOKEN_ADJUST_PRIVILEGES = &H20 Const TOKEN_QUERY = &H8 Const SE_PRIVILEGE_ENABLED = &H2 Private Type LUID UsedPart As Long IgnoredForNowHigh32BitPart As Long End Type Private Type TOKEN_PRIVILEGES PrivilegeCount As Long TheLuid As LUID Attributes As Long End Type Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Const HELP_CONTENTS = &H3& Const EWX_SHUTDOWN = 8 '关闭电源 Private Sub Form_Load() Dim hProcessHandle As Long Dim hTokenHandle As Long Dim tmpLuid As LUID Dim tkpNew As TOKEN_PRIVILEGES Dim tkpPrevious As TOKEN_PRIVILEGES Dim lBufferNeeded As Long '获取当前进程的一个伪句柄 hProcessHandle = GetCurrentProcess() OpenProcessToken hProcessHandle, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hTokenHandle LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid tkpNew.PrivilegeCount = 1 tkpNew.TheLuid = tmpLuid tkpNew.Attributes = SE_PRIVILEGE_ENABLED lBufferNeeded = 0 '允许当前应用程序有关闭操作系统的权限 AdjustTokenPrivileges hTokenHandle, False, tkpNew, Len(tkpPrevious), tkpPrevious, lBufferNeeded End Sub Private Sub Command1_Click() '关闭计算机 ExitWindowsEx EWX_FORCE Or EWX_SHUTDOWN, 0 End Sub