Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Application hiding

Posted on 1998-12-18
5
Medium Priority
?
190 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 400 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Loops Section Overview
Suggested Courses

916 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