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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Console and windows app in ONE exe

Status
Not open for further replies.

rickinger

Programmer
Feb 11, 2004
20
NL
Hi fellow programmers,

I tried to address this problem in another thread already but I guess it got too far down...

Basically what I am trying to compile is a single .exe application that runs both 1) as a windows and 2) as a console application. When the users starts the application with the mouse Form1 should appear; when he/she starts over the console, that window should *not* appear.

I got everything ready so far (thanks at this point to some of you guys); two classes, one for the form startup and one for the console startup. Through the project's properties I can assign one of these classes to be the start object. Here is the problem:

- When I define the Form class as start object, the form window will popup even when the program is started over the console.
- Defining the "console start" class as the start object, I need to code something to seperate between a start through the console or through windows. The problem: Even when the user starts the application with the mouse, the console window will appear as well! (since it is the start object). I tried different methods to close that console window but no luck yet (without shutting down the whole application)...

I'm not sure where to go from here? Does anyone have a hint for me?
 
What you are wanting to do isn't supported by the .NET framework. The designers never considered that people might want to open a console window from a Windows Forms app. Likewise, as you discovered, you can open a Windows Form from a console app, but closing the console window terminates the app.

There is a WinConsole example here that was designed by a third party, but I've not used it to determine whether or not it works. It can be found at
 
Yes, use two apps. Think of it like SQL Server. You have osql.exe and isqlw.exe. Osql allows you to run queries and perform commands at the command line, whereas isqlw opens up query analyzer in windows.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top