Knowing the process, you need to bring it flows. Who knows how to implement it? With primerchik, if possible, or a link to the source ...

Help, plz.

    1 answer 1

    There is a WinAPI function CreateToolhelp32Snapshot , which takes a snapshot of processes. You will only have to go through the list of threads and select those that are interesting for the functions Thread32First and Thread32Next .

    Example:

     uses PsAPI, TlHelp32, Windows, SysUtils; //выводит список потоков function GetThreadsInfo(PID:Cardinal): Boolean; var SnapProcHandle: THandle; NextProc : Boolean; ThreadEntry : TThreadEntry32; begin SnapProcHandle := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); //Создаем снэпшот всех существующих потоков Result := (SnapProcHandle <> INVALID_HANDLE_VALUE); if Result then try ThreadEntry.dwSize := SizeOf(ThreadEntry); NextProc := Thread32First(SnapProcHandle, ThreadEntry);//получаем первый поток while NextProc do begin if ThreadEntry.th32OwnerProcessID = PID then begin //проверка на принадлежность к процессу Writeln('Thread ID ' + inttohex(ThreadEntry.th32ThreadID, 8)); Writeln('base priority ' + inttostr(ThreadEntry.tpBasePri)); Writeln('delta priority ' + inttostr(ThreadEntry.tpBasePri)); Writeln(''); end; NextProc := Thread32Next(SnapProcHandle, ThreadEntry);//получаем следующий поток end; finally CloseHandle(SnapProcHandle);//освобождаем снэпшот end; end; 

    You can get the PID of your process using the GetCurrentProcessId function.


    UPD1. By simple manipulations with the above code, it is easy to get a function that returns the PID by the process name:

     function GetPIDByName(const name: PWideChar): Cardinal; var SnapProcHandle: THandle; ProcEntry : TProcessEntry32; NextProc : Boolean; begin Result := 0; SnapProcHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); try ProcEntry.dwSize := SizeOf(ProcEntry); NextProc := Process32First(SnapProcHandle, ProcEntry); while NextProc do begin if StrComp(name, ProcEntry.szExeFile) = 0 then Result := ProcEntry.th32ProcessID; NextProc := Process32Next(SnapProcHandle, ProcEntry); end; finally CloseHandle(SnapProcHandle); end; end; 
    • You have a typo, instead of TThreadEntry : TThreadEntry32; should be ThreadEntry : TThreadEntry32; , an extra letter Т in the variable name. - SoftR
    • @SoftR, thanks - Nofate
    • Please describe the full view of the compilation, how and what to do ... and the question: is there a process, you need to output its streams ... pls, help, you need urgently ... - Manitikyl
    • For a console application: take the above function, and pass the process PID to it. She will bring you information on the processes. If you need for example to display this in Memo, edit the block with Writeln accordingly. - Nofate
    • More specifically? you need to find the pokot from the process and give it privileges by the function SetThreadPriority ... can you put where the source is? - Manitikyl