파워빌더/공통함수
파워빌더.공통함수 - 실행중인 파일명 찾기
농부지기
2017. 1. 26. 23:55
[ 파워빌더.공통함수 - 실행중인 파일명 찾기 ]
☞ |
|
현재 윈도우에서 해당 파일명으로 프로세스가 실행중인지 아닌지 알고 싶을 때,
다음과 같이 해서도 찾을 수 있습니다.
외부함수 선언)
Function ulong CreateToolhelp32Snapshot (ulong dwFlags, ulong th32ProcessID) Library "KERNEL32.DLL" Function boolean Process32First (ulong hSnapshot, ref PROCESSENTRY32 lppe) Library "KERNEL32.DLL" alias for "Process32First;Ansi" Function boolean Process32Next (ulong hSnapshot, ref PROCESSENTRY32 lppe) Library "KERNEL32.DLL" alias for "Process32Next;Ansi" Function boolean CloseHandle (ref ulong hObject) Library "KERNEL32.DLL" Function ulong GetCurrentProcess() Library "KERNEL32.DLL" Alias For "GetCurrentProcess"
스트럭쳐 선언)
global type PROCESSENTRY32 from structure ulong dwSize ulong cntUsage ulong th32ProcessID ulong th32DefaultHeapID ulong th32ModuleID ulong cntThreads ulong th32ParentProcessID long pcPriClassBase ulong dwFlags character szExeFile[260] end type
스크립트)
비교하고자 하는 파일이 실행중이면 True, 그렇지 않으면 False 를 Return
String ls_File_nm //비교할 실행파일명
ulong ll_SnapShot ulong lul_null boolean lb_Res,lb_rtn = false string ls_exefile //읽어온 프로세스의 실행파일명 PROCESSENTRY32 lstr_Entry
SetNull(lul_null)
ll_SnapShot = CreateToolhelp32Snapshot(15, lul_null)
lstr_Entry.dwSize = 1506 // structure의 size
// 실행중인 프로세스들의 첫번째 정보를 가져온다. Process32First(ll_SnapShot, lstr_Entry) if lstr_Entry.szExeFile = ls_File_nm then lb_rtn = true ELSE
do while true lb_Res = Process32Next(ll_SnapShot,lstr_Entry); if not lb_Res then exit //더이상 프로세스가 없으면 Exit ls_exefile = trim(lstr_Entry.szExeFile) ls_exefile = trim(ls_exefile) if ls_exefile = ls_File_nm then lb_rtn = true loop
END IF
CloseHandle(ll_SnapShot)
return lb_rtn
|