Visual_Basic 板


LINE

※ 引述《kandrew (蓝天白云~~)》之铭言: : Hi chino,谢谢您提供此方法!! : 我利用此方法,确实可以侦测到特定的程式是否结束, : 但如果标题会改变的程式,就比较难侦测到了, : 例如要侦测小画家是否结束,当你开新档时小画家的标题为"未命名-小画家" : 然後再开另一个图档则标题则变为"xxxx-小画家",这样就会判断失败了。 : 是否还有别的函数可以判断部分标题名称的函式,例如只判断"小画家" : 如果如此,这样就可以正确的侦测出程式是否结束了。 : ※ 引述《chinoyan (chino)》之铭言: : : 'API宣告 : : Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal : : lpClassName As String, ByVal lpWindowName As String) As Long : : ' 视窗的class ,"XXX"视窗标题,不知class填vbNullString即可 : : ' 传回值为window hwnd, 不存在传回 0 : : If FindWindow(vbNullString, "XXX") <> 0 Then : : End If '方法一 Dim Pid as long pid = GetPsPid("小画家.exe") If pid <> 0 Then End If Option Explicit ' IN 模组 Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long) Private Const TH32CS_SNAPPROCESS = &H2& Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * 260 End Type Const PROCESS_TERMINATE = 1 Function GetPsPid(sProcess As String) As Long Dim lSnapShot As Long Dim lNextProcess As Long Dim tPE As PROCESSENTRY32 lSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&) If lSnapShot <> -1 Then tPE.dwSize = Len(tPE) lNextProcess = Process32First(lSnapShot, tPE) Do While lNextProcess If LCase$(sProcess) = LCase$(Left(tPE.szExeFile, InStr(1, tPE.szExeFile, Chr(0)) - 1)) Then Dim lProcess As Long Dim lExitCode As Long GetPsPid = tPE.th32ProcessID CloseHandle lProcess End If lNextProcess = Process32Next(lSnapShot, tPE) Loop CloseHandle (lSnapShot) End If End Function ============================================================================= '方法二 EnumWindows AddressOf EnumWindowsProc, 0& '引用 'in 模组 Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean On Error Resume Next Dim S As String S = String(40, 0) Call GetWindowText(hwnd, S, 40) S = Left(S, InStr(S, Chr(0)) - 1) If Len(S) > 0 Then If InStr(S, "小画家") > 0 Then ' End If End If EnumWindowsProc = True ' 表示继续列举 hWnd End Function -- ████ █ ★ ████ █ █ █ █ █ █ █ █ █ 超 级 热 烈 欢 迎 █ ████ █ █ █ ████ █ █ █ █ █ ███★ █ █ 欢迎到嘉义版! ★███ █ █ █ █ █ █ █ 讯驰电脑-路径嘉义市林森西路496号(05)2244-526顺发斜对面 --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.33.214.160
1F:推 JacobTai:就是想推原po的热心 10/06 09:38
2F:推 kandrew:我利用方法二,成功侦测出特定程式是否结束。感谢C大!!! 10/06 17:27
3F:推 MacPerson:太热心了 ~~~ 推 10/06 21:32
4F:→ MacPerson:有code128的经验谈分享吗 @@ 10/06 21:33
5F:→ chinoyan:CODE 128 是什麽?? 10/06 21:36
6F:→ MacPerson:code 128 条码字型 最近光搞这就饱了..... 10/06 21:42
7F:→ chinoyan:RS232 没玩过.SORRY 10/07 01:40







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:e-shopping站内搜寻

TOP