Solved

Application hiding

Posted on 1998-12-18
5
181 Views
Last Modified: 2013-11-20
When i run a MFC created application it appears in the list of tasks (when ctrl + alt + del) is pressed. I don't want my application to be visible there, is is possible to do this?
I am using windows 95, VC++ 5.0
0
Comment
Question by:jayku
  • 3
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 1326373
To do this, you could register the application as a Win95 service,e.g.:
// from http://support.microsoft.com/support/kb/articles/q125/7/14.asp,
// How to Start an Application at Boot Time Under Windows 95
// Last reviewed: September 25, 1995
// Article ID: Q125714

// Define                    Value       Meaning
#define RSP_SIMPLE_SERVICE        0x00000001    // Registers the process as a
                                                // simple service process.
#define RSP_UNREGISTER_SERVICE    0x00000000    // Unregisters the process as a
                                                // service process.

HANDLE          g_hSvcDll       =   NULL;

typedef DWORD ( *RSPPROC)   (   DWORD,  DWORD);

RSPPROC RegisterServiceProcess;

            g_hSvcDll   =   LoadLibrary (   "kernel32.dll");

            if  (   !g_hSvcDll)
                {
                      // error
                }

            RegisterServiceProcess  =   ( RSPPROC)  GetProcAddress  (   g_hSvcDll,
                                                                        "RegisterServiceProcess"
                                                                    );

            if  (   !RegisterServiceProcess)
                {
                    FreeLibrary (   g_hSvcDll);
                }
             else
                {
                    if  (   !RegisterServiceProcess (   GetCurrentProcessId (),
                                                        RSP_SIMPLE_SERVICE
                                                    )
                        )
                        {
                          // error
                        }
                }

0
 

Author Comment

by:jayku
ID: 1326374
Yes I tried it works fine.. but the answer is half as you should also tell me how to remove the process from memory? or the process itself has to kill itself.. pl. explain.
thanks for the answer
0
 
LVL 86

Expert Comment

by:jkr
ID: 1326375
Well, to unregister it, simply use
                    if  (   !RegisterServiceProcess (   GetCurrentProcessId (),
                                                        RSP_UNREGISTER_SERVICE    
                                                    )
                        )
                        {
                          // error
                        }

To remove it from memory, simply terminate the program as usual, (e.g. using 'ExitProcess()').
But i think your problem is to get notified when to terminate - one easy way would be to set up an 'invisible' window, e.g.

WNDCLASS wndclass;
MSG      uMsg;
HWND     hWnd;


     wndclass.lpszClassName = "InvisibleApp";
     wndclass.hInstance     = hInstance;
     wndclass.lpfnWndProc   = WndProc;
     wndclass.hCursor       = LoadCursor(NULL,IDI_APPLICATION);
     wndclass.hIcon         = LoadIcon(0,IDI_EXCLAMATION);
     wndclass.lpszMenuName  = NULL;
     wndclass.hbrBackground = COLOR_BACKGROUND+1;
     wndclass.style         = NULL;
     wndclass.cbClsExtra    = 0;
     wndclass.cbWndExtra    = 0;

     RegisterClass(&wndclass);


    hWnd=CreateWindow(  "InvisibleApp",
                        "InvisibleApp",
                        WS_OVERLAPPEDWINDOW|WS_ICONIC,
                        CW_USEDEFAULT,
                        0,
                        CW_USEDEFAULT,
                        0,
                        NULL,
                        NULL,
                        hInstance,
                        NULL);

   while(GetMessage(&uMsg,0,0,0))
        {
         TranslateMessage(&uMsg);
         DispatchMessage(&uMsg);
        };


LONG FAR PASCAL WndProc(HWND     hWnd,
                        unsigned uMsg,
                        WPARAM   wParam,
                        LPARAM   lParam)
{
  //Process messages  
   switch(uMsg)
   {
    case WM_ENDSESSION: ExitProcess ( 0); break;
    default:       return(
                          DefWindowProc(hWnd,
                                        uMsg,
                                        wParam,
                                        lParam)
                         );

    return  ( 0);
}

Or, in MFX, simply override CWnd::OnEndSession ...
0
 
LVL 86

Expert Comment

by:jkr
ID: 1326376
Sorry, MFX sould of course read MFC ;-)
0
 

Author Comment

by:jayku
ID: 1326377
Thanks I works fine

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 113
List out all word 7 259
WinWaitActive parameters 12 31
twoTwo  challenge 35 93
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now