home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / Debugger / java_debugger / DebuggeeProcess.java next >
Encoding:
Java Source  |  2000-05-04  |  1.1 KB  |  44 lines

  1. //
  2. // DebuggeeProcess.java
  3. //
  4. // (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  5. //
  6.  
  7. import com.ms.win32.*;
  8. import java.io.IOException;
  9.  
  10. public class DebuggeeProcess
  11. {
  12.     protected int m_nMainThreadHandle;
  13.     protected int m_nProcessID;
  14.  
  15.     public void CreateSuspendedProcess (String sCommandLine) throws IOException
  16.     {
  17.         STARTUPINFO si = new STARTUPINFO();
  18.         PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
  19.         if (Kernel32.CreateProcess(null, sCommandLine, null, null, false, winc.CREATE_SUSPENDED, 0, null, si, pi))
  20.         {
  21.             m_nMainThreadHandle = pi.hThread;
  22.             m_nProcessID = pi.dwProcessId;
  23.         }
  24.         else
  25.         {
  26.             throw new IOException("CreateProcess");
  27.         }
  28.     }
  29.  
  30.     public int GetProcessID()
  31.     {
  32.         return(m_nProcessID);
  33.     }
  34.  
  35.     public void ResumeProcess () throws IOException
  36.     {
  37.         if (Kernel32.ResumeThread(m_nMainThreadHandle) == (int)0xffffffff)
  38.             throw new IOException("ResumeThread");
  39.         Kernel32.CloseHandle(m_nMainThreadHandle);
  40.         m_nMainThreadHandle = wini.INVALID_HANDLE_VALUE;
  41.     }
  42. }
  43.  
  44.