dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Hide a program from another program

  1. #1
    Join Date
    Dec 2017
    Posts
    38

    Hide a program from another program

    Is there a way to hide a program from another program using it's process handle?

    Code:
    #include <iostream>
    #include <windows.h>
    #include <cstdio>
    #include <tlhelp32.h>
    
    using namespace std;
    
    int main()
    {
    	PROCESSENTRY32 entry;
        entry.dwSize = sizeof(PROCESSENTRY32);
    
        HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    
        if (Process32First(snapshot, &entry) == TRUE)
        {
            while (Process32Next(snapshot, &entry) == TRUE)
            {
                if (strcmp(entry.szExeFile, "notepad.exe") == 0)
                {
                    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
    
    				// Hide if program was found in the task manager
    				// ShowWindow(FindWindow(NULL, "asd"), SW_HIDE);
    
                    CloseHandle(hProcess);
                }else{
    				// The program wasn't found
                }
            }
        }
    
        return 0;
    }

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,262

    Re: Hide a program from another program

    You could take the idea from this MSDN article: https://support.microsoft.com/en-us/...eanly-in-win32
    You would need only some code snippets for 32/bit App and rather than post the WM_CLOSE message just call ::ShowWindow(hwnd, SW_HIDE);
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)