Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create app that doesn't show screen output

Status
Not open for further replies.

shanlon

Technical User
Dec 4, 2000
24
0
0
IE
Is there an option in VC++ to create an application that just does some function without displaying a screen.. i want to run this application on a server from a client machine and then have it disappear without the user having to 'press any key to continue' as is the case with creating a Win32 console application.

It has to have support for MFC included as i'm using sockets.
The machine is running Win2000.
 
I believe that it will be only possible using a non window software like turbo c++ or borland c++ 3.1b that program in 16 bits.
The problem is....and what about MFC.....well....we can never score all the time ...if you catch my drift.
 
thanks for that Arowana...

I've just thought about what my original question and concluded that it doesn't ultimately need to show nothing to the screen.

It's going to be a server application that is listening for a client to connect.. when the client connects it sends back messages and such.
Ideally the program will be constantly running on the server and waiting for this connection to occur.. when the client shuts down, the listening socket on the server stays open and waits for the conection to occur again at a later stage.

Maybe having something in the sys-tray would be the solution.. if it popped up upon connection and disappeared back down again to the tray when finished??
OR
Even if i the program brings up a window is there a way for me to close this window lets say when the server connection gets the OnClose message.

Would you know how to do these or have you any suggestions?

Thanks for your help so far.





 
I have basically the same problem. I'm doing all my I/O through TCL/TK, but the console window still pops up because everything's integrated into a C++ win32 console program..
I find it hard to believe that there's no way to hide the window without switching to a lesser compiler. Seems like it's be a fairly common thing..
 
OK. If you set /subsystem:windows in the linker options, it doesn't give you a console window. The downside is that for sooome reason, your entry point then has to be WinMain instead of Main. It has a different set of arguments, and more importantly - for me - I already need my main function to be called sc_main to use system C.

Does anyone know what's going on behind this?

Also, if you don't mind the console window popping up for a split second, if you start your program with

#ifdef __win32__
FreeConsole();
#endif

it'll make it disappear. I don't really like this 'solution' though..
 
1. If You use MFC-based application (for example, created with AppWizard), You have InitInstance() function in it. In this Function, comment out the line:
pMainFrame->ShowWindow(m_nCmdShow);
2. If not, hook WM_SHOWWINDOW message or edit it's handler to avoid showing of main window.

 
Shanlon,

seems to me you should write a service instead of a "normal" program. A service runs without any interaction, even when no user is logged in to the system (server). Look in the Platform SDK documentation, "Base Services", "Dll's, Processes, and Threads", "Services".

Marcel
 
IIRC, in VC++, the "press any key to continue" only when you run your code within the IDE (ctrl-F5, or from main menu, Build -> Execute).

You can create a console app with MFC support.

You can crate a shortcut to your console app; in the shortcut property, select "minimize" in the "Run:" drop down listbox. You can also run your console app through another app (GUI or console), using CreateProcess() API. in the StartupInfo struct, select SW_HIDE for the wShowWindow field, and STARTF_USESHOWWINDOW for dwFlag field.

HTH
Shyan
 
Why don't you create an application of type Win 32 Application.

Implement within everything you need for your server to listen to the specified port, but DO NOT implement window with a message loop as in all win32 programs.

To add an icon in the system tray use shell function SHNotifyIcon. There are few samples within MSDN.

I have made something similar but in VB(a web server). However the kit is avalable for download from my site below.

HTH, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
All you need to do is have your window show and hide itself based on the connection events. In handling the client connect/disconnect events, just call ShowWindow() appropriately.
 
How abt writing a service... this would not display any console window. Sockets and other networking services work fine with the NT service arch. However, if your program is going to access Shared dirves and other shared objects, then there is a problem. But is has a way around also.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top