| | |
Write silent program
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 18
Reputation:
Solved Threads: 1
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?
<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?
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.
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
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
![]() |
Similar Threads
- Need help to write jdbc program (JSP)
- HELP!! trying to write a quiz program part 1 (C++)
- Write from CPP program to serial port (C++)
- How can i write program that writes into a file from an array of string and reverse (C++)
- Trying to write to a file so that another program can read from it at the same time (C++)
- Write a calculator program using a do-while loop (C++)
- C expert help me! Write a TSR program that changes the background color ... (C)
- can we write linlist program in java (Java)
- Can you please help me write this word count program in another way (Python)
- Trying to write a program for an assignment... (Java)
Other Threads in the C Forum
- Previous Thread: code to convert binary to decimal
- Next Thread: how to scan arrow keys from keyboard in c?
Views: 362 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C
* adobe api append array arrays bash binarysearch char character cm copyanyfile copypdffile createcopyoffile createprocess() csyntax directory drawing dynamic executable execv feet fgets file floatingpointvalidation fork frequency function getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux highest homework i/o ide infiniteloop initialization interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list lowest matrix meter microsoft mqqueue multi mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scheduling segmentationfault send single socketprogramming spoonfeeding stack standard strchr string student suggestions system test testautomation unix urboc user whythiscodecausesegmentationfault win32 win32api windows.h





