473,473 Members | 4,297 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can we determine at runtime if app is Console or Windows?

Hi all, and to Cor, Herfried and the other "old folks", it's been a long
time :-)

I might be hanging around again for awhile but in the meantime I have a
question. Does anybody know of a way to determine at runtime whether the
app is a console or a GUI app? I have to imagine the information is
available but searching around didn't yield the answer.

Thanks,
Tom


Oct 9 '06 #1
4 1866
Hi Tom,

Good to see you back, in my idea is this a typical Herfried question.
I am almost sure he knows this.

Cor

"Tom Leylan" <ge*@iamtiredofspam.comschreef in bericht
news:%2***************@TK2MSFTNGP02.phx.gbl...
Hi all, and to Cor, Herfried and the other "old folks", it's been a long
time :-)

I might be hanging around again for awhile but in the meantime I have a
question. Does anybody know of a way to determine at runtime whether the
app is a console or a GUI app? I have to imagine the information is
available but searching around didn't yield the answer.

Thanks,
Tom


Oct 9 '06 #2
Hi to you too... (you're an MVP now)!

It might sound a little funny since it must be known at compile time whether
it is a console app. On the other hand I was hoping that I might develop a
few routines that would adapt depending upon whether it was a console app,
so I would like to check at runtime. It might not turn out to be too useful
but I thought I'd check.

Anything else been going on?
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:er**************@TK2MSFTNGP03.phx.gbl...
Hi Tom,

Good to see you back, in my idea is this a typical Herfried question.
I am almost sure he knows this.

Cor

"Tom Leylan" <ge*@iamtiredofspam.comschreef in bericht
news:%2***************@TK2MSFTNGP02.phx.gbl...
>Hi all, and to Cor, Herfried and the other "old folks", it's been a long
time :-)

I might be hanging around again for awhile but in the meantime I have a
question. Does anybody know of a way to determine at runtime whether the
app is a console or a GUI app? I have to imagine the information is
available but searching around didn't yield the answer.

Thanks,
Tom

Oct 9 '06 #3
Tom Leylan wrote:
I might be hanging around again for awhile but in the meantime I have
a question. Does anybody know of a way to determine at runtime
whether the app is a console or a GUI app?
Seeing as no one else has answered, I'll offer you this solution. I don't
like it at all, but it does work (tested in VB2005):

\\\
Public Function IsConsole() As Boolean

Dim s As String

Try
s = Console.Title
Return True
Catch ex As System.IO.IOException
Return False
End Try

End Function
///

I'd strongly advise keeping this in a self-contained function, and then when
someone suggests a proper implementation you can just swap the code over. :)

--

(O)enone
Oct 9 '06 #4
That works well enough. I agree that catching the exception isn't the idea
method but the functionality is isolated. I added a static variable within
the function so it can be set once on the first call and subsequent calls
don't need to trip the exception again.

Thanks... it works!
"Oenone" <oe****@nowhere.comwrote in message
news:FX*****************@newsfe7-gui.ntli.net...
Tom Leylan wrote:
>I might be hanging around again for awhile but in the meantime I have
a question. Does anybody know of a way to determine at runtime
whether the app is a console or a GUI app?

Seeing as no one else has answered, I'll offer you this solution. I don't
like it at all, but it does work (tested in VB2005):

\\\
Public Function IsConsole() As Boolean

Dim s As String

Try
s = Console.Title
Return True
Catch ex As System.IO.IOException
Return False
End Try

End Function
///

I'd strongly advise keeping this in a self-contained function, and then
when someone suggests a proper implementation you can just swap the code
over. :)

--

(O)enone

Oct 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SHC | last post by:
Hi all, I did the "Build" on the attached code in my VC++ .NET 2003 - Windows XP Pro PC. On the c:\ screen, I got the following: Microsoft Development Environment An unhandled exception of type...
5
by: Markus Stehle | last post by:
Hi all! I have asp.net web application that uses static impersonation. Is it possible to change the impersonated user during runtime? Within some parts of my application I would like to...
6
by: Stu | last post by:
with the following code snippet Dim ConOra As OracleConnection = New OracleConnection() ConOra.ConnectionString = "User Id=USER;Password=PASSWORD;Data Source=orcl9i;" Dim Sql As String =...
3
by: Dean Slindee | last post by:
I have a exception handling class that could be called from either a windows project app or a console project app. Is there any way for this class to determine which type of app called it without...
3
by: Lars Netzel | last post by:
Hello! I need to Send/Receive in Outlook from vb.net and have followed this code (It's c# but it works fine in VB.NET after translating too) http://support.microsoft.com/default.aspx?id=310251...
1
by: mgonzales3 | last post by:
I have a windows app that i want to be able to run at the cmd line. Using vs2005 can I determine the Output Type at runtime? or can I set this value at runtime? thanks
7
by: semedao | last post by:
Hi all, I view many posts about this issue , the connected property does not tell us the current status of the socket. based on couple of suggestions of msdn , and some article here , I try to...
2
by: Rymfax | last post by:
Hey all. I need to determine whether or not a Windows Driver is digitally signed using a C# application. Can anyone point me in the right direction for doing this? I know it has something to...
7
by: Cramer | last post by:
I'm wondering if there is an easy way to programmatically determine if an assembly is installed in the GAC. This would be similar to our ability to easily determine if a file exists...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.