Is Process Alive 
تابعی برای تعیین باز بودن پروسس
Const MAX_PATH = 260
Const TH32CS_SNAPPROCESS = 2&
Private Type PROCESSENTRY32
    lSize            As Long
    lUsage           As Long
    lProcessId       As Long
    lDefaultHeapId   As Long
    lModuleId        As Long
    lThreads         As Long
    lParentProcessId As Long
    lPriClassBase    As Long
    lFlags           As Long
    sExeFile         As String * MAX_PATH
End Type
 
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
 
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" _
    Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, _
    ByVal lProcessId As Long) As Long
    
Private Declare Function ProcessFirst Lib "kernel32" _
    Alias "Process32First" (ByVal hSnapshot As Long, _
    uProcess As PROCESSENTRY32) As Long
    
Private Declare Function ProcessNext Lib "kernel32" _
    Alias "Process32Next" (ByVal hSnapshot As Long, _
    uProcess As PROCESSENTRY32) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
    ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
 
Function IsProcessAlive(pId As Long) As Boolean
Dim sExeName   As String
Dim sPid       As String
Dim sParentPid As String
Dim lSnapShot  As Long
Dim r          As Long
Dim uProcess   As PROCESSENTRY32
 
Dim fProc As Long
IsProcessAlive = False
lSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
uProcess.lSize = Len(uProcess)
r = ProcessFirst(lSnapShot, uProcess)
 Do While r
    If uProcess.lProcessId = pId Then
     IsProcessAlive = True
     Exit Do
    End If
    r = ProcessNext(lSnapShot, uProcess)
Loop
CloseHandle (lSnapShot)
 
End Function
--------------------
بستن Process بر اساس Pid 
تابعی برای بستن پروسس بر اساس آی دی پروسس
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
    ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, _
    ByVal uExitCode As Long) As Long
Public Sub EndProcessPerID(fProc As Long)
 
 Dim mProcID As Long
 mProcID = OpenProcess(1&, -1&, fProc)
 TerminateProcess mProcID, 0&
 
End Sub
--------------------
hWnd to Process ID
تابعی برای تبدیل hWnd به Pid
Private Const GW_HWNDNEXT = 2
 
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
 
Public Function hWndToPid(ByVal My_hwnd As Long) As Long
Dim test_hwnd As Long
Dim test_pid As Long
Dim test_thread_id As Long
 
    " Get the first window handle.
    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
 
    " Loop until we find the target or we run out
    " of windows.
    Do While test_hwnd <> 0
        " See if this window has a parent. If not,
        " it is a top-level window.
        If GetParent(test_hwnd) = 0 Then
            " This is a top-level window. See if
            " it has the target instance handle.
            test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
 
            If test_hwnd = My_hwnd Then
                " This is the target.
                hWndToPid = test_pid
                Exit Do
            End If
        End If
 
        " Examine the next window.
        test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    Loop
End Function
--------------------
ProcessID to hWnd
تابعی برای تبدیل Pid به hwnd
Private Const GW_HWNDNEXT = 2
 
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
 
" Return the window handle for an instance handle.
Public Function PidTohWnd(ByVal target_pid As Long) As Long
Dim test_hwnd As Long
Dim test_pid As Long
Dim test_thread_id As Long
 
    " Get the first window handle.
    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
 
    " Loop until we find the target or we run out
    " of windows.
    Do While test_hwnd <> 0
        " See if this window has a parent. If not,
        " it is a top-level window.
        If GetParent(test_hwnd) = 0 Then
            " This is a top-level window. See if
            " it has the target instance handle.
            test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
 
            If test_pid = target_pid Then
                " This is the target.
                PidTohWnd = test_hwnd
                Exit Do
            End If
        End If
 
        " Examine the next window.
        test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    Loop
End Function
--------------------
فرستادن پیام به برنامه در حال اجرا
ابنم یه سورس توپ
کارش فرستادن پیام برای برنامه در حال اجراست
اگه شما دوتا برنامه داشته باشین، که از تنظیمات یکسانی توی هردو استفاده کرده باشین، با این روش می تونید با تغییر تنظیمات در هر کدوم از برنامه ها، اون رو به اطلاع برنامه دیگه هم برسونید. به نظر من که عالیه.
 
دانلود