Solved

Application hiding

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 87
iSeries FTP Exit Program 8 114
Detect CR LF to each line 12 137
Unix Command -- Challenging  question 7 79
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

19 Experts available now in Live!

Get 1:1 Help Now