怎样判断进程是否启动??

cg2003 2004-04-30 02:46:31
我要在别的程序中调用VB的EXE文件(有窗口),首先我需要判断这个进程是否启动,如启动我要将他显示到前面,如没有启动我再启动它,应该怎样做??是要在初始化的时候做判断吧
...全文
91 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzj34 2004-04-30
  • 打赏
  • 举报
回复
楼上讲得好清楚了,有可能会出现shell32.dll
hhyttppd 2004-04-30
  • 打赏
  • 举报
回复
UP
ryuginka 2004-04-30
  • 打赏
  • 举报
回复
up
wumy_ld 2004-04-30
  • 打赏
  • 举报
回复
FindWindow

VB声明
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
说明
寻找窗口列表中第一个符合指定条件的顶级窗口(在vb里使用:FindWindow最常见的一个用途是获得ThunderRTMain类的隐藏窗口的句柄;该类是所有运行中vb执行程序的一部分。获得句柄后,可用api函数GetWindowText取得这个窗口的名称;该名也是应用程序的标题)
返回值
Long,找到窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastError
参数表
参数 类型及说明
lpClassName String,指向包含了窗口类名的空中止(C语言)字串的指针;或设为零,表示接收任何类
lpWindowName String,指向包含了窗口文本(或标签)的空中止(C语言)字串的指针;或设为零,表示接收任何窗口标题
注解
很少要求同时按类与窗口名搜索。为向自己不准备参数传递一个零,最简便的办法是传递vbNullString常数

示例
Dim hw&, cnt&
Dim rttitle As String * 256
hw& = FindWindow("ThunderRT5Main", vbNullString) ' ThunderRTMain under VB4
cnt = GetWindowText(hw&, rttitle, 255)
MsgBox Left$(rttitle, cnt), 0, "RTMain title"
wumy_ld 2004-04-30
  • 打赏
  • 举报
回复
Option Explicit
Private Const SW_SHOW = 5
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub Command1_Click()
Dim lngHWnd As Long

lngHWnd = FindWindow("ThunderRT6MDIForm", "国际金融组织贷款管理系统")

If lngHWnd = 0 Then
ShellExecute Me.hwnd, "open", "D:\Program Files\LONGREATWAY\国际金融组织贷款管理系统\LoanManager.exe", vbNullString, App.Path, SW_SHOW
End If
End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧