Results 1 to 32 of 32

Thread: [RESOLVED] Attach Program to Another So If It's Terminated, So Will the Other

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Resolved [RESOLVED] Attach Program to Another So If It's Terminated, So Will the Other

    I'm trying to create a program that monitors the activities of the program, and if the monitoring program is terminated, so will the other. I noticed how debuggers do this when they attach themselves to another program, so I would like the code to do something like that.
    Last edited by abazabam; Jul 24th, 2005 at 03:52 PM.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I liked the code from http://pscode.com/vb/scripts/ShowCod...41711&lngWId=1, but it was too long and complicated for me. I don't want any debugging stuff. I just want the code to attach the program to another.

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Is all you're looking to do is to terminate a VB program when a non-VB program terminates?

    You say attach (which you won't have to do) and monitor (what other monitoring will there be?)

  4. #4
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    You could do something like this:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    5. Private Const WM_CLOSE = &H10
    6.  
    7. Private Sub Form_Unload(Cancel As Integer)
    8. Dim hWndNotepad As Long
    9.  
    10.     'get handle to Notepad
    11.     hWndNotepad = FindWindow("Notepad", vbNullString)
    12.     'close notepad
    13.     If hWndNotepad <> 0 Then _
    14.         SendMessage hWndNotepad, WM_CLOSE, 0, 0
    15.  
    16. End Sub

    This program shuts down notepad before exiting.
    Also, it lets you know if Notepad is running or not by updating a label

    Edit: removed uneeded stuff
    Last edited by moeur; Jul 24th, 2005 at 04:43 PM.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I need a really simple code. Moeur, the code you gave me wouldn't work for what I'm trying to do. If the monitoring program is terminated, the other program will still be running. I'm talking about the monitoring program, not the program that's being monitored.

  6. #6
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    No, this "monitoring" program terminates the other program (in this case Notepad) when someone closes the monitoring program.
    Last edited by moeur; Jul 24th, 2005 at 04:44 PM.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I know. I want the program so that if the monitoring program is terminated, so will the program being monitored.

  8. #8
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    OK, I'm confused.
    Is the monitoring program a 3rd program, or the one we're writing?

    You can just add the above code to the monitoring program and then the monitored program will close when you close the monitoring program.

    In this case, Notepad closes when I close my program.
    Last edited by moeur; Jul 24th, 2005 at 04:48 PM.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Okay fine. Let me try to make it simpler. I want it to do exactly what a debugger does, without the debugging stuff. If you attach a program to a debugger and you terminate the debugger, the program being debugged will also be terminated.

  10. #10
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    and this code does exactly that.

    In this case my code goes in the debugger and Notepad is the program being debugged.

    Did you try it?

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I guess I could use that, but I wanted it more like this:

    Private Declare Function DebugActiveProcess Lib "kernel32" (ByVal dwProcessId As Long) As Long

    Private Sub Form_Load()
    DebugActiveProcess Shell("c:\myprogram.exe", vbNormalFocus)
    End Sub

    I got this far, and this is exactly what I wanted except the program being debugged is frozen.

  12. #12
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Well, you've got two conflicting requirements.
    1. Keep it simple.
    2. attach a debugger.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I know debuggers are very complicated, that's why I just want to know how to use the DebugActiveProcess API to attach the program and not have the program being attached freeze.

  14. #14
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I'm also very confused. If you don't want to debug the other process why do you want to use the DebugActiveProcess function? That function will suspend all threads in the foreign process and send the current state of the process to your application. You must call the WaitForDebugEvent function and process all debugging events sent to your application. These events include CREATE_PROCESS_DEBUG_EVENT which represent the process currently being debugged. You will then get a CREATE_THREAD_DEBUG_EVENT for each thread started by the process. Furthermore a LOAD_DLL_DEBUG_EVENT is sent for each and every DLL that is loaded in the foreign process memory space.

    It's your job to then resume all threads that has been started by the process and also resume the loading of each DLL the process want to load into memory. Until that is done the process will appear frozen since your application has taken over the job normally handled by Windows simply because you're debugging the process.

    But then again, you stated that you wanted to start debugging without doing any debugging which to me sounds funny. I assume that you actually just want to monitor the application and unload it when your application ends, or do you wish to end your application when the foreign process ends? This is very confusing indeed.

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Okay, let me explain exactly, what I'm trying to do. I'm just trying to create a time trial wrapper in VB. The monitoring program will monitor how long the program has been running and if the user uses the program too long the monitoring program will close itself and the program. However, the monitoring program can easily be terminated with the program to be monitored still running, so the user can use it as long as he or she wants.

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Can you just give me a code or upload a code to do this? I've always liked my code to be as short and simple as possible, but it's not possible to do that, can you at least make it as short and basic as possible?

  17. #17
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    What is wrong with using the code I already provided?
    I think it is the simplest code that will do the job.
    Or, do you need help with the other functions of your monitoring program?

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I just want to use the DebugActiveProcess API in the code. I never really liked SendMessage and FindWindow.

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Maybe I'll just make another post about DebugActiveProcess

  20. #20
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I think you are wrong about how a debugee will act when the debugger is shut down. It will continue to run. Here is the simplest debugger I could write. You can see for yourself.
    VB Code:
    1. ption Explicit
    2.  
    3. Private isRunning As Boolean
    4. Private ProcessID As Long
    5.  
    6. Private Const PROCESS_ALL_ACCESS = &H100FFF
    7.  
    8. Private Type PROCESS_INFORMATION
    9.     hProcess As Long
    10.     hThread As Long
    11.     dwProcessId As Long
    12.     dwThreadId As Long
    13. End Type
    14.  
    15. Private Type STARTUPINFO
    16.     cb As Long
    17.     lpReserved As String
    18.     lpDesktop As String
    19.     lpTitle As String
    20.     dwX As Long
    21.     dwY As Long
    22.     dwXSize As Long
    23.     dwYSize As Long
    24.     dwXCountChars As Long
    25.     dwYCountChars As Long
    26.     dwFillAttribute As Long
    27.     dwFlags As Long
    28.     wShowWindow As Integer
    29.     cbReserved2 As Integer
    30.     lpReserved2 As Byte
    31.     hStdInput As Long
    32.     hStdOutput As Long
    33.     hStdError As Long
    34. End Type
    35.  
    36. Private Enum ProcessCreationFlags
    37.     DEBUG_PROCESS = &H1
    38.     DEBUG_ONLY_THIS_PROCESS = &H2
    39.     CREATE_SUSPENDED = &H4
    40.     DETACHED_PROCESS = &H8
    41.     CREATE_NEW_CONSOLE = &H10
    42.     NORMAL_PRIORITY_CLASS = &H20
    43.     IDLE_PRIORITY_CLASS = &H40
    44.     HIGH_PRIORITY_CLASS = &H80
    45.     REALTIME_PRIORITY_CLASS = &H100
    46.     CREATE_NEW_PROCESS_GROUP = &H200
    47.     CREATE_UNICODE_ENVIRONMENT = &H400
    48.     CREATE_SEPARATE_WOW_VDM = &H800
    49.     CREATE_SHARED_WOW_VDM = &H1000
    50.     CREATE_FORCEDOS = &H2000
    51.     CREATE_DEFAULT_ERROR_MODE = &H4000000
    52.     CREATE_NO_WINDOW = &H8000000
    53. End Enum
    54.  
    55. Private Declare Function CreateProcess Lib _
    56.     "kernel32" Alias "CreateProcessA" ( _
    57.     ByVal lpApplicationName As String, _
    58.     ByVal lpCommandLine As String, _
    59.     ByVal lpProcessAttributes As Long, _
    60.     ByVal lpThreadAttributes As Long, _
    61.     ByVal bInheritHandles As Long, _
    62.     ByVal dwCreationFlags As Long, _
    63.     ByVal lpEnvironment As Long, _
    64.     ByVal lpCurrentDirectory As String, _
    65.     lpStartupInfo As STARTUPINFO, _
    66.     lpProcessInformation As PROCESS_INFORMATION _
    67. ) As Long
    68.  
    69.  
    70. 'Debugging event code that identifies the type of
    71. '  debugging event.
    72. Private Const EXCEPTION_DEBUG_EVENT = 1
    73. Private Const CREATE_THREAD_DEBUG_EVENT = 2
    74. Private Const CREATE_PROCESS_DEBUG_EVENT = 3
    75. Private Const EXIT_THREAD_DEBUG_EVENT = 4
    76.  
    77. Private Const LOAD_DLL_DEBUG_EVENT = 6
    78. Private Const UNLOAD_DLL_DEBUG_EVENT = 7
    79. Private Const OUTPUT_DEBUG_STRING_EVENT = 8
    80. Private Const RIP_EVENT = 9
    81.  
    82. Private Const EXCEPTION_BREAKPOINT = &H80000003
    83. Private Const DBG_CONTINUE = &H10002
    84. Private Const DBG_TERMINATE_THREAD = &H40010003
    85. Private Const DBG_TERMINATE_PROCESS = &H40010004
    86. Private Const DBG_CONTROL_C = &H40010005
    87. Private Const DBG_CONTROL_BREAK = &H40010008
    88. Private Const DBG_EXCEPTION_NOT_HANDLED = &H80010001
    89. Private Const EXIT_PROCESS_DEBUG_EVENT = 5
    90. Private Const EXCEPTION_MAXIMUM_PARAMETERS = 15
    91.  
    92. Private Type DEBUG_EVENT
    93.   dwDebugEventCode As Long
    94.   dwProcessId As Long
    95.   dwThreadId As Long
    96.   union(0 To 87) As Byte
    97. End Type
    98.  
    99.     Private Type EXCEPTION_RECORD
    100.        ExceptionCode As Long
    101.        ExceptionFlags As Long
    102.        pExceptionRecord As Long    ' Pointer to an EXCEPTION_RECORD structure
    103.        ExceptionAddress As Long
    104.        NumberParameters As Long
    105.        ExceptionInformation(EXCEPTION_MAXIMUM_PARAMETERS) As Long
    106.     End Type
    107.    
    108.     Private Type EXCEPTION_DEBUG_INFO
    109.         pExceptionRecord As EXCEPTION_RECORD
    110.         dwFirstChance As Long
    111.     End Type
    112.  
    113. Private Declare Function OpenProcess Lib "kernel32" ( _
    114.     ByVal dwDesiredAccess As Long, _
    115.     ByVal bInheritHandle As Long, _
    116.     ByVal dwProcessId As Long _
    117. ) As Long
    118.  
    119. Private Declare Function WaitForDebugEvent Lib "kernel32" ( _
    120.     lpDebugEvent As DEBUG_EVENT, _
    121.     ByVal dwMilliseconds As Long _
    122. ) As Integer 'Bool
    123.  
    124. Private Declare Function DebugActiveProcess Lib "kernel32" ( _
    125.     ByVal dwProcessId As Long _
    126. ) As Long
    127.  
    128. Private Declare Function DebugActiveProcessStop Lib "kernel32" ( _
    129.     ByVal dwProcessId As Long _
    130. ) As Long
    131.  
    132. Private Declare Function ContinueDebugEvent Lib "kernel32" ( _
    133.     ByVal dwProcessId As Long, _
    134.     ByVal dwThreadId As Long, _
    135.     ByVal dwContinueStatus As Long _
    136. ) As Long
    137.  
    138. Private Declare Function CloseHandle Lib "kernel32" ( _
    139.     ByVal hObject As Long _
    140. ) As Long
    141.  
    142. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
    143.     Destination As Any, _
    144.     Source As Any, _
    145.     ByVal Length As Long _
    146. )
    147.  
    148. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    149.     ByVal lpClassName As String, _
    150.     ByVal lpWindowName As String _
    151. ) As Long
    152.  
    153. Private Declare Function GetWindowThreadProcessId Lib "user32" ( _
    154.     ByVal hwnd As Long, _
    155.     lpdwProcessId As Long _
    156. ) As Long
    157.  
    158. Private Sub Command1_Click()
    159.     Dim hWndNtPD As Long
    160.     Dim hProc As Long
    161.    
    162.     'get handle to Window if it is open
    163.     hWndNtPD = FindWindow("SciCalc", vbNullString)
    164.    
    165.     'if program has not started then start it
    166.     If hWndNtPD = 0 Then
    167.         Dim PINFO As PROCESS_INFORMATION
    168.         Dim si As STARTUPINFO
    169.    
    170.         si.cb = Len(si)
    171.         If CreateProcess(vbNullString, "C:\Windows\system32\calc.exe", 0&, 0&, 0&, _
    172.             DEBUG_ONLY_THIS_PROCESS, 0&, _
    173.             vbNullString, si, PINFO) Then
    174.                 ProcessID = PINFO.dwProcessId
    175.                 hProc = PINFO.hProcess
    176.         Else
    177.             MsgBox "CreateProcess failed"
    178.             Exit Sub
    179.         End If
    180.        
    181.     Else
    182.         'program is already running, open its process
    183.         If GetWindowThreadProcessId(hWndNtPD, ProcessID) = 0 Then
    184.             MsgBox "Error Getting ProcessID"
    185.             Exit Sub
    186.         End If
    187.    
    188.         hProc = OpenProcess(PROCESS_ALL_ACCESS, 0&, ProcessID)
    189.         If hProc = 0 Then
    190.             MsgBox "Error Opening process"
    191.             Exit Sub
    192.         End If
    193.        
    194.         If DebugActiveProcess(ProcessID) = 0 Then
    195.             CloseHandle hProc
    196.             MsgBox "Error Attaching Debugger"
    197.             Exit Sub
    198.         End If
    199.  
    200.        
    201.     End If
    202.    
    203. '    The debug loop.  Runs until the debuggee terminates
    204.    Dim dbgevent As DEBUG_EVENT
    205.    Dim dwContinueStatus As Long
    206.     isRunning = True
    207.     Do
    208.         'wait here for 100ms for debug event
    209.         If WaitForDebugEvent(dbgevent, 100) Then
    210.             Debug.Print "Debug Event: "; dbgevent.dwDebugEventCode
    211.            
    212.             If dbgevent.dwDebugEventCode = EXCEPTION_DEBUG_EVENT Then
    213.                 dwContinueStatus = HandleException(dbgevent)
    214.             Else
    215.                 dwContinueStatus = DBG_CONTINUE
    216.             End If
    217.             'continue debugging
    218.             Call ContinueDebugEvent(dbgevent.dwProcessId, _
    219.                             dbgevent.dwThreadId, _
    220.                                     dwContinueStatus)
    221.         Else
    222.             'no debug event occurred
    223.             DoEvents
    224.         End If
    225.     Loop While (dbgevent.dwDebugEventCode <> EXIT_PROCESS_DEBUG_EVENT) And isRunning
    226.    
    227.     isRunning = False
    228.    
    229. End Sub
    230.  
    231. Private Sub Form_Unload(Cancel As Integer)
    232.     isRunning = False
    233.     DebugActiveProcessStop ProcessID
    234. End Sub
    235.  
    236. Private Function HandleException(dbgevent As DEBUG_EVENT) As Long
    237.     Dim dwContinueStatus As Long
    238.    
    239.     Dim exceptRec As EXCEPTION_RECORD
    240.     Dim Exception As EXCEPTION_DEBUG_INFO
    241.     Call CopyMemory(Exception, dbgevent.union(0), Len(Exception))
    242.     Call CopyMemory(exceptRec, Exception.pExceptionRecord, Len(exceptRec))
    243.         Debug.Print
    244.         Debug.Print "Exception code: ";
    245.         Debug.Print Hex(exceptRec.ExceptionCode); "  Addr: ";
    246.         Debug.Print Hex(exceptRec.ExceptionAddress)
    247.  
    248.     ' If it isn't a breakpoint, we don't want to know about it.
    249.     If exceptRec.ExceptionCode <> EXCEPTION_BREAKPOINT Then
    250.         HandleException = DBG_EXCEPTION_NOT_HANDLED
    251.         Exit Function
    252.     End If
    253.     dwContinueStatus = DBG_CONTINUE
    254.    
    255.     HandleException = dwContinueStatus
    256.  
    257. End Function

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Thanks so much! That's exactly what I needed! Are you sure that if you terminate the debugger, the debugged program doesn't terminate, also? It does for this computer and my old computer, too.
    Last edited by abazabam; Jul 24th, 2005 at 10:46 PM.

  22. #22
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Well, I'm using XP which might be different than what you are using. Try it.

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I don't get it. I'm using Windows XP SP2. Maybe you don't understand what I'm talking about. Here's what I did. I copied and pasted your code into VB and then I compiled it to an executable(c:\test.exe). Then I ran test.exe and clicked Command1. I opened the Task Manager, clicked the Processes tab and terminated test.exe. Calc.exe was also terminated.

  24. #24
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    The problem was that I was running it out of the IDE, once I compiled it it works as you say.
    Also I had to remove
    VB Code:
    1. DebugActiveProcessStop ProcessID
    from the Form_Unload event

    Have fun with it.

  25. #25

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    How would I terminate Calc.exe using TerminateProcess? I tried "isRunning = False: DebugActiveProcessStop ProcessID: TerminateProcess ProcessID, 0", but it didn't work.

  26. #26
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    This code I gave you terminates calc.exe when it is closed; right?


    Your method should be
    VB Code:
    1. TerminateProcess hProc,0

    Check out this thread for many ways to kill a program
    http://www.vbforums.com/showthread.p...minate+process
    and this one
    http://www.vbforums.com/showthread.p...minate+process
    Last edited by moeur; Jul 26th, 2005 at 09:41 AM.

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    You were right. It was hProc not ProcessId. Also, how do I lock calc.exe after I have ran the process? It's for my trial wrapping program, so I need it so that no one can copy and paste calc.exe to somewhere else, easily.(My program to be protected will be in the place of calc.exe). I tried using "Lock #FileNum", CreateFile, and OpenFile, but none of them worked. Also, If I didn't even have the calc.exe window open, I don't even need to use DebugActiveProcess?

  28. #28
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    You'll still be able to start the 'calc' program without starting your debug program, so what is the point if it's a trial program? Won't they see the other .exe?

  29. #29
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    I don't think you can lock a file.
    You could just rename it, move it to another directory and hide it.

    BTW I think you owe me one here so why not rate my post?

    Gotta get to that 100 mark so I've resorted to begging

  30. #30
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Stop whining moeur... I've tried to give you some rep points here but I can't since I've done it already... Maybe not in this thread but I need to spread it around a bit... So why don't you start giving me some rep points as well

  31. #31

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    It doesn't matter if you can see the .exe as long as it can't be copied somewhere else. As soon as the trial is over, or the program is exited, the debugging program will delete the .exe. It's not even close to being foolproof but I'm trying my best.

  32. #32

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: Attach Program to Another So If It's Terminated, So Will the Other

    Actually, I can't seem to delete the file after I stop debugging it. I tried, "isRunning = False", "DebugActiveProcessStop ProcessID", "DebugActiveProcessStop hProc", and "TerminateProcess hProc, 0" but they didn't work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width