EaBIM一直以来积极响应国家“十二五”推进建筑业信息化的号召,对建筑领域的信息技术开展深入技术交流和探讨!致力于打造“BIM-建筑师-生态技术”三位一体综合资源交流共享平台,希望为BIM与可持续设计理念及技术的普及做出微小的贡献!!!

EaBIM

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 822|回复: 0
打印 上一主题 下一主题

从AutoCAD2006开始引入了动态块这个概念,动态块的使用使得我们的图形更加灵活,可...

[复制链接]

1514

主题

7465

帖子

1万

积分

admin

Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10

积分
12406

社区QQ达人

跳转到指定楼层
楼主
发表于 2014-1-8 14:05:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. 网上找到得,判断某程序是否运行Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
  2. Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
  3. Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
  4. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  5. Private Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hProcess As Long, ByRef lphModule As Long, ByVal cb As Long, ByRef cbNeeded As Long) As Long
  6. Private Declare Function GetModuleFileNameExA Lib "psapi.dll" (ByVal hProcess As Long, ByVal hModule As Long, ByVal ModuleName As String, ByVal nSize As Long) As Long
  7. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  8. Private Const TH32CS_SNAPHEAPLIST = &H1
  9. Private Const TH32CS_SNAPPROCESS = &H2
  10. Private Const TH32CS_SNAPTHREAD = &H4
  11. Private Const TH32CS_SNAPMODULE = &H8
  12. Private Const TH32CS_SNAPALL = TH32CS_SNAPPROCESS + TH32CS_SNAPHEAPLIST + TH32CS_SNAPTHREAD + TH32CS_SNAPMODULE
  13. Private Const PROCESS_TERMINATE = 1
  14. Private Const PROCESS_QUERY_INFORMATION = 1024
  15. Private Const PROCESS_VM_READ = 16
  16. Private Const PROCESS_ALL_ACCESS = &H1F0FFF
  17. Private Const MAX_PATH = 260
  18. Private Type PROCESSENTRY32
  19.     dwsize As Long
  20.     cntusage As Long
  21.     th32ProcessID As Long
  22.     th32DefaultHeapID As Long
  23.     th32ModuleID As Long
  24.     cntThreads As Long
  25.     th32ParentProcessID As Long
  26.     pcPriClassBase As Long
  27.     dwFlags As Long
  28.     szExeFile As String * MAX_PATH
  29. End Type
  30. Public Function IsProcessRun(exeName As String) As Boolean
  31.     Dim snap As Long, ret As Long, lProcess As Long
  32.     Dim proc As PROCESSENTRY32
  33.     Dim mName As String * MAX_PATH, modName As String
  34.     snap = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0)
  35.     proc.dwsize = Len(proc)
  36.     ret = ProcessFirst(snap, proc)
  37.     Do While ret <> 0
  38.         mName = ""
  39.         Dim Modules(1 To MAX_PATH) As Long, cbMNeeded As Long
  40.         lProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, True, proc.th32ProcessID)
  41.         If lProcess <> 0 Then
  42.             ret = EnumProcessModules(lProcess, Modules(1), MAX_PATH, cbMNeeded)
  43.             If ret <> 0 Then ret = GetModuleFileNameExA(lProcess, Modules(1), mName, Len(mName))
  44.             modName = Trim(Left(mName, ret))
  45.             If InStr(LCase(modName), LCase(exeName)) Then
  46.                 CloseHandle snap
  47.                 IsProcessRun = True
  48.                 Exit Function
  49.             End If
  50.         End If
  51.         ret = ProcessNext(snap, proc)
  52.     Loop
  53.     CloseHandle snap
  54.     IsProcessRun = False
  55. End Function
  56. 使用的时候:Dim temp As Boolean
  57.                      temp = IsProcessRun("ACAD.exe")


复制代码
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 反对反对
工作时间:工作日的9:00-12:00/13:30-18:00,节假日不在线,请勿留言
*滑块验证:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|EaBIM网 ( 苏ICP备2020058923号-1  苏公网安备32011502011255号

GMT+8, 2024-11-27 06:53

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表