Vb.net关闭设备 vbnet关闭一个窗体
如何在编的VB.NET程序使用时关闭电脑
有两种方法,第一种是调用shutdown.exe
创新互联建站专注为客户提供全方位的互联网综合服务,包含不限于做网站、成都做网站、凉山州网络推广、重庆小程序开发公司、凉山州网络营销、凉山州企业策划、凉山州品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联建站为所有大学生创业者提供凉山州建站搭建服务,24小时服务热线:18982081108,官方网址:www.cdcxhl.com
shell("shutdown.exe路径 -s -t 0") '-t是延迟时间,0表示立刻关机
另一种就是使用API了,好像是ExitWindow,你可以去搜索一下其用法。
怎样才能用VB.NET的代码来关闭一个在运行的程序
软糖来回答罗:通过System.Diagnostics命名空间下的Process类来关闭程序的进程
Dim 进程集合 = Process.GetProcessesByName("进程名称")
For Each 进程 In 进程集合
进程.Kill()
'进程.Close() '或者使用关闭
Next
也可以先获取所有进程,再来判断这些进程的名称ProcessName
Dim 获取本地所有进程 = Process.GetProcesses()
For Each 进程 In 获取本地所有进程
If 进程.ProcessName = "explorer.exe" Then 进程.Kill()
Next
请问VB.NET的关机语句是?
这是点击Option 你可以
用个msgbox函数 点击YES时候运行关机代码即可
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
Const EWX_FORCE As Short = 4
Const EWX_LOGOFF As Short = 0
Const EWX_REBOOT As Short = 2
Const EWX_SHUTDOWN As Short = 1
Dim retval As Integer
' 定义Esc按键
Const VK_ESCAPE As Short = H1Bs
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
If Option1.Checked Then
' 注销当前用户
retval = ExitWindowsEx(EWX_FORCE, 0) bitsCN.Com
ElseIf Option2.Checked Then
' 关闭计算机
retval = ExitWindowsEx(EWX_SHUTDOWN, 0)
ElseIf Option3.Checked Then
' 重新启动
retval = ExitWindowsEx(EWX_REBOOT, 0)
End If
End Sub
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
Me.Close()
End Sub
' 按Esc键时,结束应用程序
Private Sub Form1_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
If KeyAscii = VK_ESCAPE Then BBS.bitsCN.com网管论坛
Me.Close()
End If
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
VB.net智能设备开发,如何重新调用已关闭的窗体
A窗口里面代码:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim B As Form2 = New Form2
objfrm.Show()
End Sub
B窗口里面
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
me.close()
End Sub
这是B窗体关闭A还在 只要点A里面的BUTTON B就会show
前提必须是A是主窗体
网站栏目:Vb.net关闭设备 vbnet关闭一个窗体
转载注明:http://myzitong.com/article/dodpghc.html