110,571
社区成员
发帖
与我相关
我的任务
分享
Public Class Class1
Public Shared Sub Main(ByVal aaa() As String)
Dim asdasdas As New form1
Dim ObjMyProcess As Process()
ObjMyProcess = Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)
'问了防止二重启动
If ObjMyProcess.Length > 1 Then
'第二次开始想显示在最前面.....
asdasdas.Show()
Return
End
End If
Dim frm As New Form1
Application.Run(frm)
End Sub
End Class
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As IntPtr) As Integer
Public Shared Sub Main(ByVal aaa() As String)
Dim p As Process() = Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName) 'Process.GetCurrentProcess.ProcessName)
'防止程序启动多次,只有一个运行的实例
If p.Length > 1 Then
'将之前启动的窗体显示出来。
SetForegroundWindow(p(0).MainWindowHandle)
End '退出软件
End If
'正常情况下的窗体显示
Application.Run(New Form1())
End Sub
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As IntPtr) As Integer
Public Shared Sub Main(ByVal aaa() As String)
Dim p As Process() = Process.GetProcessesByName("VBWin02") 'Process.GetCurrentProcess.ProcessName)
'防止程序启动多次,只有一个运行的实例
If p.Length > 1 Then
'将之前启动的窗体显示出来。
SetForegroundWindow(p(0).MainWindowHandle)
End '退出软件
End If
'正常情况下的窗体显示
Application.Run(New Form1())
End Sub
Public Shared Sub Main(ByVal aaa() As String)
Dim asdasdas As New Form1
Dim ObjMyProcess As Process()
ObjMyProcess = Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)
'问了防止二重启动
If ObjMyProcess.Length > 1 Then
'第二次开始想显示在最前面.....
Application.Run(asdasdas)
Return
'找到已启动的窗体句柄 然后将其显示出来
'
'code
'
'同时将这个程序关闭
Application.Exit()
'End
End If
Dim frm As New Form1
Application.Run(frm)
End Sub