Solved

Application hiding

Posted on 1998-12-18
5
183 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pressing cancel button with C# UI Automation 3 80
Expand macro to ask for filename column 8 37
Named range not carried over 10 65
has77  challenge 9 88
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

809 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