Solved

Application hiding

Posted on 1998-12-18
5
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
pre4 challenge 19 110
Annoying "thing" blocks my view 4 133
how to split multiple lines delimiter : 8 119
Problem to App 4 119
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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