0

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?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by SecurExpert
0

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.

Edited by MosaicFuneral: n/a

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.