Hirdetés
- Honor Magic8 Pro - bevált recept kölcsönvett hozzávalókkal
- Neked tükröt, az iPhone Airnek emléket állít a Realme
- Soundcore Sleep A30 - a hosszú házasság titka
- Honor Magic V2 - origami
- Szívós, szép és kitartó az új OnePlus óra
- Google Pixel topik
- Az órádnál fogva vezet nyomra az új Apple AirTag
- Yettel topik
- Apple iPhone 6s - Nyomás utána!
- Redmi Note 15 Pro 5G – a szokásosat?
-
Mobilarena

Új hozzászólás Aktív témák
-
pmonitor
aktív tag
válasz
sztanozs
#16528
üzenetére
Készítettem tesztprogramot C-ben, csak nem tudom, hogy mikor tudom hosszasan futtatni. pidtesztA:
#include <windows.h>
HINSTANCE hInstance = NULL;
char* AppName = "PID teszt \"A\"";
char* WindowClassName = "pidtesztA";
HWND AppHwnd = NULL;
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int main()
{
WNDCLASSEX wc;
MSG msg;
hInstance = GetModuleHandle(NULL);
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hbrBackground = COLOR_BTNFACE + 1;
wc.hInstance = hInstance;
wc.lpszMenuName = NULL;
wc.lpszClassName = WindowClassName;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClassEx(&wc);
AppHwnd = CreateWindowEx(0, WindowClassName, AppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1200, 900, 0, 0, hInstance, 0);
ShowWindow(AppHwnd, SW_SHOWDEFAULT);
UpdateWindow(AppHwnd);
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
ShowWindow(AppHwnd, SW_NORMAL);
break;
case WM_COMMAND:
break;
case WM_SIZE:
{
break;
}
case WM_SHOWWINDOW:
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
break;
}
}pidtesztB:
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
STARTUPINFOA SI;
PROCESS_INFORMATION PI;
HWND Pids[400000000];
int PidsP = 0;
int waitmsec = 500;
int appStart(char name[])
{
if (!CreateProcessA(NULL, name, NULL, NULL, FALSE, 0, NULL, NULL, &SI, &PI))
{
printf("A %s file-t nem lehet megnyitni...\n", name);
return -1;
}
WaitForSingleObject(PI.hProcess, waitmsec);
return 0;
}
int main(int argc, char* argv[])
{
DWORD procid = 0, hwndid;
ZeroMemory(&SI, sizeof(SI));
SI.cb = sizeof(SI);
ZeroMemory(&PI, sizeof(PI));
if (argc == 3) waitmsec = atoi(argv[2]);
char appA[50] = "pidtesztA.exe";
char appAClass[50] = "pidtesztA";
if (!appStart(appA))
{
HWND hwnd = FindWindowExA(NULL, NULL, appAClass, NULL);
while (hwnd)
{
int pidact = 0;
int tid = GetWindowThreadProcessId(hwnd, &pidact);
Pids[PidsP] = pidact;
PidsP++;
hwnd = FindWindowExA(NULL, hwnd, appAClass, NULL);
}
TerminateProcess(PI.hProcess, 0);
}
HWND prochwnd;
int i, out = 0, imax = 500;
if (argc >= 2) imax = atoi(argv[1]);
for (i = 0; i < imax; i++)
{
ZeroMemory(&SI, sizeof(SI));
SI.cb = sizeof(SI);
ZeroMemory(&PI, sizeof(PI));
if (!appStart(appA))
{
HWND hwnd = FindWindowExA(NULL, NULL, appAClass, NULL);
while (hwnd)
{
int pidact = 0;
int tid = GetWindowThreadProcessId(hwnd, &pidact);
int j = 0;
while (j < PidsP)
{
if (Pids[j] == pidact)
{
printf("Pid egyezik!\n");
out = 1;
break;
}
j++;
}
if (out) break;
Pids[PidsP] = pidact;
PidsP++;
hwnd = FindWindowExA(NULL, hwnd, appAClass, NULL);
}
TerminateProcess(PI.hProcess, 0);
if (out) break;
}
}
printf("i: %d\n", i);
return 0;
}Mint látható az "A" egy standard window. A "B" console. Az indítási intervallum, és a waitforsingleobject() ideje is alapból 500, de parancssorból változtatható, mint az a kódból is látható. A szám adatok validitását nem ellenőriztem le, csak egyből konvertál(legalábbis megpróbál
).
Még nem tudtam hosszan futtatni. Ha vki. működésbeli hibát vesz észre, Ő kérem jelezze.
Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
- Azonnali fáradt gőzös kérdések órája
- Audi, Cupra, Seat, Skoda, Volkswagen topik
- Forza sorozat (Horizon/Motorsport)
- Autóápolás, karbantartás, fényezés
- Tőzsde és gazdaság
- Hardcore café
- A fociról könnyedén, egy baráti társaságban
- Bittorrent topik
- Megkezdte az idei cicaharcot az AMD és az Intel
- EAFC 26
- További aktív témák...
- Telefon felvásárlás!! Samsung Galaxy Note 10+/Samsung Galaxy Note 20/Samsung Galaxy Note 20 Ultra
- Apple iPhone 17 Pro Max 256GB,Újszerű,Dobozaval,24 hónap garanciával
- BESZÁMÍTÁS! Gigabyte Z390 i7 9700K 16GB DDR4 512GB SSD RX 7600 8GB Kolink VOID ADATA 600W
- Lenovo ThinkPad X1 Active Noise Cancellation fejhallgató
- Panasonic LUMIX G 25mm f/1.7 ASPH objektív
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: Central PC számítógép és laptop szerviz - Pécs
Város: Pécs

).

