Как сделать так, чтобы проект в Visual Studio отображался в обозревателе процессов?

1
7

Мне нужно получить доступ к потоку процесса в проекте Visual Studio в Process Explorer. Я не могу его найти, я пытался найти его во время его выполнения, после его завершения и до него. Не знаю, важно ли это, но code

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>  // For malloc and free

struct MyStruct {
    INT a;
    INT b;
};

DWORD WINAPI bla(LPVOID lparam) {
    struct MyStruct* nums = (struct MyStruct*)lparam;
    INT count = nums->a + nums->b;
    for (INT i = 1; i <= count; i++) {
        printf("bla\n");
        Sleep(1000);
    }
    return 0;  // Typically, thread functions return 0 for success
}

int main()
{
    struct MyStruct* my_struct = (struct MyStruct*)malloc(sizeof(struct MyStruct));
    if (my_struct == NULL) {
        fprintf(stderr, "Memory allocation failed\n");
        return 1;
    }
    my_struct->a = 3;
    my_struct->b = 4;
    LPVOID pstruct = my_struct;
    HANDLE hThread = CreateThread(
        NULL, //default security attributes
        0, //default stack size
        bla, //thread function
        pstruct, //thread param
        0, //default creation flags
        NULL //return thread identifier
    );
    if (hThread == NULL) {
        fprintf(stderr, "Failed to create thread\n");
        free(my_struct);  // Free memory if thread creation fails
        return 1;
    }
    WaitForSingleObject(hThread, INFINITE);
}
Аверкий
Вопрос задан2 марта 2024 г.

1 Ответ

Ваш ответ

Загрузить файл.