Write silent program

Thread Solved

Join Date: Sep 2009
Posts: 18
Reputation: SecurExpert is an unknown quantity at this point 
Solved Threads: 1
SecurExpert SecurExpert is offline Offline
Newbie Poster

Write silent program

 
0
  #1
Oct 13th, 2009
I wish to write a program that works in the background, i.e. without showing any windows. Someone prescribed i try this:
<code>
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
while(1)
{
Sleep(1000);
}

return 0;
}
<code>
but its not working. it still shows the CMD window. I am using Dev-C++. Could anyone advice me?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 949
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark
 
0
  #2
Oct 13th, 2009
One, you have to specify to the linker that it's a windowed application.

Then you get the window handle, and with ShowWindow(), in the second parameter use SW_HIDE.

edit:
You'll probably also want to look into lowering the task priority.
Last edited by MosaicFuneral; Oct 13th, 2009 at 9:19 pm.
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 18
Reputation: SecurExpert is an unknown quantity at this point 
Solved Threads: 1
SecurExpert SecurExpert is offline Offline
Newbie Poster
 
0
  #3
Oct 18th, 2009
Well, thanx. I have tried it but the compiler gives me so many errors and i still quite dont get it. By the way i am using vc++. Mind giving me a sample code? Will really appreciate. Thanx.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC