'程序以模块中的Sub Main启动 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function ShowWindow Lib "user32" (ByVal Hwnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function SetForegroundWindow Lib "user32" (ByVal Hwnd As Long) As Long Private Const SW_SHOWNORMAL = 1Sub Main() Dim WinWnd As Long, s As String On Error Resume Next App.Title = "" s = "图形浏览" WinWnd = FindWindow(vbNullString, s) If WinWnd <> 0 Then ShowWindow WinWnd, SW_SHOWNORMAL SetForegroundWindow WinWnd End End If App.Title = s
Load frmMain End Sub
If App.PrevInstance Then MsgBox ("图形浏览程序已经运行。"), vbExclamation else shell "c:\图形浏览.exe c.jpg" End If
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal Hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal Hwnd As Long) As Long
Private Const SW_SHOWNORMAL = 1Sub Main()
Dim WinWnd As Long, s As String
On Error Resume Next
App.Title = ""
s = "图形浏览"
WinWnd = FindWindow(vbNullString, s)
If WinWnd <> 0 Then
ShowWindow WinWnd, SW_SHOWNORMAL
SetForegroundWindow WinWnd
End
End If
App.Title = s
Load frmMain
End Sub
MsgBox ("图形浏览程序已经运行。"), vbExclamation
else
shell "c:\图形浏览.exe c.jpg"
End If
有关DDE通信的详细说明,请看 VB 帮助文件。