获取任务管理器的活动元素

时间:2011-05-28 17:02:29

标签: c++ winapi

好的,我想从Windows任务管理器的应用程序列表中删除我的应用程序。我找到了以下代码: http://www.codeproject.com/KB/system/Hack_Windows_Task_Manager.aspx

我想在C / C ++中这样做,所以我编码:

#define WIN32_LEAN_AND_MEAN 
#include <windows.h>
#include <iostream>

BOOL CALLBACK Usun(HWND hwnd,LPARAM lParam);
int main()
{
    HWND hwnd;
    while (true)
    {
        hwnd = FindWindow(NULL,"Menedżer zadań Windows"); //<-- it's in polish and it is finding window without problems
        if (hwnd == NULL) std::cout << "Not found" << std::endl;
        else
        {
            std::cout << "Found" << std::endl;
            EnumChildWindows(hwnd,Usun,NULL);
            Sleep(500);
        }
    }
    std::cin.get();
    return 0;
}

BOOL CALLBACK Usun(HWND hwnd,LPARAM lParam)
{
    char zakladka[256] = {0};
    GetWindowText(hwnd,zakladka,256);
    char lista[256] = {0};
    GetClassName(hwnd,lista,256);
    if ((strcmp(zakladka,"Aplikacje") == 0) && (strcmp(lista,"SysListView32") == 0))
    { //Aplikacje is the same as Tasks
        std::cout << "Found SysList" << std::endl;
    }
    return TRUE;
}

但是程序没有按照它应该的方式工作。

重要提示:这不是一些病毒程序

1 个答案:

答案 0 :(得分:2)

我认为您还应该从任务栏中隐藏您的应用。请检查此http://www.codeproject.com/KB/dialog/hidetaskbar.aspx