Új hozzászólás Aktív témák

  • sztanozs

    veterán

    válasz pmonitor #16505 üzenetére

    Futtattam pénteken egy tesztet: ~300K process indításból csak kb 3000 egyedi PID volt. HWND egyezést csak egyet sikerült előidéznem, azt közvetlenül a gép újraindítása után.
    C# (form) kód:
    using System;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.IO;

    namespace pidtest {
    public partial class Form1 : Form {
    [DllImport("user32.dll", SetLastError = true)]
    static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
    public Form1() { InitializeComponent(); }

    private void Form1_Load(object sender, EventArgs e) {
    try {
    uint pid;
    IntPtr hwnd = Handle;
    GetWindowThreadProcessId(Handle, out pid);
    using (StreamWriter w = File.AppendText(@"c:\temp\pidtest.txt")) {
    w.WriteLine("{0} {1}", pid.ToString(), hwnd.ToString());
    } }
    finally { Close(); }
    }
    }
    }

    python teszter:
    import os
    a=0
    f=open("c:/temp/pidtest.txt","r");A=f.readlines()
    while 1:
    os.startfile("c:/temp/pidtest.exe")
    A+=f.readlines()
    if len(A) != len({*A}): break
    if a%100==0:
    B,C=zip(*[a.split()for a in A])
    D,E={*B},{*C}
    print(f'Items: {len(B)} - Unique: {len(D)} PID, {len(E)} HWND', end='\r', flush=1)
    a+=1
    f.close()

Új hozzászólás Aktív témák

Hirdetés