Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to create a background process ?

Posted on 2001-06-13
33
Medium Priority
?
276 Views
Last Modified: 2010-04-02
I want to make my program as a background process on Win9x (or as a Service on WinNT/2000). That means users will not know the process is running, and the task manager will only show the process on the "Processes" tab, NOT on the "Applications" tab.

*** I want to do it by using API calls. ***

Please tell me how to do it.
Which API calls can help ?
Also, the code should work on Win9x/NT/2000/ME.

Thanx!


MW
0
Comment
Question by:Raymond
[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
  • 13
  • 7
  • 5
  • +5
33 Comments
 
LVL 5

Expert Comment

by:proskig
ID: 6187601
Look for examples on this page
http://www.codeguru.com/system/index.shtml
0
 
LVL 32

Expert Comment

by:jhance
ID: 6187602
You start a new process from one application using the Windows CreateProcess() API call.  In the STARTUPINFO structure you can specify that the window should be hidden (i.e. it won't show up on the desktop or on the taskbar) if you set wShowWindow to SW_HIDE and the dwFlags to include STARTF_USESHOWWINDOW.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6187671
>>>*** I want to do it by using API calls. ***

What OTHER way is there?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:Axter
ID: 6187865
Just by using the ShowWindow API, you can get your program out of the "Application Tab".

ShowWindo(hWnd,SW_HIDE);
0
 
LVL 30

Expert Comment

by:Axter
ID: 6187869
Oops! type-o
That should have been:

ShowWindow(hWnd,SW_HIDE);
0
 

Author Comment

by:Raymond
ID: 6187991
Axter:

"ShowWindow(hWnd,SW_HIDE)" does not work, my program still appear on the Application Tab of task manager.


regards,
MW
0
 
LVL 32

Expert Comment

by:jhance
ID: 6188081
Since you choose to totally ignore my comment, I'll have to post it again as an ANSWER this time....


You start a new process from one application using the Windows CreateProcess() API call.  In the STARTUPINFO
structure you can specify that the window should be hidden (i.e. it won't show up on the desktop or
on the taskbar) if you set wShowWindow to SW_HIDE and the dwFlags to include STARTF_USESHOWWINDOW.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6188144
Where in your application did you put ShowWindow?
Make sure you're hiding the main window of your application.

I just tested it out on an NT4.0 machine, and it did take it out of the Application Tab.

What OS are you using?

jhance,
I think the questioner is referring to the current application, and not a newly launched application.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6188434
>>I think the questioner is referring to the current application, and not a newly launched application.

That may well be but he could at least tell me to go take a hike...
0
 
LVL 30

Expert Comment

by:Axter
ID: 6188849
I agree. :-)
0
 

Author Comment

by:Raymond
ID: 6189619
Axter, jhance:

As Axter said, my question is referring to the current application, and not a newly launched application, so I can't accept your answer, jhance. Sorry.

I am using Win2000 Prof.
I did try to hide the main window of my application.
However, "ShowWindow(hWnd,SW_HIDE)" does not hide my program, it still appear on the Application Tab of task manager.

What can I do ?


regards,
MW
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189749
Just to clear something.
Do You want this:
To see active window from your application, and to not see this in taskbar ?
0
 

Author Comment

by:Raymond
ID: 6189787
No.
My application will totally hide from users, only the TASK MANAGER will show my application on the "Processes" tab ( NOT on the "Applications" tab).

Please help!!!


Regards,
MW
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189805
Is any visual component in your application (Windows) ?
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189808
Is any visual component in your application (Windows) ?
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189812
Is any visual component in your application (Windows) ?
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189814
Is any visual component in your application (Windows) ?
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189816
Is any visual component in your application (Windows) ?
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189817
Is any visual component in your application (Windows) ?
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189818
Sorry !
Some error with Opera automatic reload option.
0
 

Author Comment

by:Raymond
ID: 6189835
Yes. One dialog like windows, but it is useless, just for debuging and testing. Users will not interact with it.


MW
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189878
Is this window visible ?
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189897
Is this window visible ?
0
 

Author Comment

by:Raymond
ID: 6189898
No, it is not visible.
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189911
Is it Visual C MFC application ?
0
 

Author Comment

by:Raymond
ID: 6189927
Is it relevant ?
0
 
LVL 2

Accepted Solution

by:
MadYugoslav earned 400 total points
ID: 6189961
It may be.
In MFC if this is dialog based application or MDI/SDI in InitInstance of your application after You create main window and set m_pMainWnd to that window You should call m_pMainWnd->ShowWindow(SW_HIDE).
0
 

Author Comment

by:Raymond
ID: 6189979
Did you test it ?
In Win2000, my application still show on Application tab of task manager.

MW
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6189993
I use Windows 2000 Pro.
This is what I use in a few applications.
Can You post your initinstance, and kind of application DLG/MDI/SDI and DLL/EXE ?
0
 
LVL 1

Expert Comment

by:Viesturs
ID: 6203010
If you wanna hide program from task manager you can use

typedef DWORD (__stdcall *pRegFunction)(DWORD, DWORD);

     HINSTANCE          hKernelLib;
     pRegFunction     RegisterServiceProcess;

     hKernelLib = LoadLibrary("kernel32.dll");
     if (hKernelLib){
      RegisterServiceProcess = (pRegFunction)GetProcAddress(hKernelLib, "RegisterServiceProcess");
      if (RegisterServiceProcess)
         RegisterServiceProcess(GetCurrentProcessId(), 1);
     }
0
 
LVL 1

Expert Comment

by:jizhang
ID: 6203435
Why not simply use:

ShellExecute(m_hWnd, "open", "C:\\BIN\\my.exe",NULL, NULL, SW_HIDE);

"...", may be in format _T("..."),
if you have parameters, fill out in 4th arg.




0
 
LVL 30

Expert Comment

by:Axter
ID: 6203444
jizhang,
The questioner is trying to do this to the current program, not one he/she is trying to launch.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6678405
Please return to this question and finalize it.  It is nearly 6 months later, much help offered and still open.  

Indidentally, I've advised you on another question that homework questions are covered in the Guidelines and Agreement in terms of acedemic honesty.  Details c/o the Help Desk link on the left.

Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

604 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