Beispiel #1
0
        /// <summary>
        /// Searches through processes on the system to determine the child process of the specified
        /// process ID...
        /// </summary>
        /// <param name="processID"></param>
        public static Int32 GetChildProcess( Int32 processID )
        {
            PROCESSENTRY32 processEntry = new PROCESSENTRY32( );
            processEntry.dwSize = 296; // Size of the PROCESSENTRY32 struct...
            //processEntry.th32DefaultHeapID = new UIntPtr( 0 );
            //processEntry.szExeFile = new char[260];

            // Get a handle to the snapshot...
            IntPtr hSnapshotHandle = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );

            // Get the first Process...
            if ( Process32First( hSnapshotHandle, ref processEntry ) )
            {
                if ( processEntry.th32ParentProcessID == processID )
                {
                    return processEntry.th32ProcessID;
                }
            }

            while ( Process32Next( hSnapshotHandle, ref processEntry ) )
            {
                if ( processEntry.th32ParentProcessID == processID )
                {
                    return processEntry.th32ProcessID;
                }
            }

            return 0;
        }
Beispiel #2
0
 public static extern bool Process32Next( IntPtr hSnapshot, ref PROCESSENTRY32 processEntry32 );