RE: How to tell if running in console or winexe mode?



Using VB and framework 1.1,
Dim b As Boolean = System.Windows.Forms.Application.MessageLoop
b is true if a message pump is running on the current thread, and false if
not. This gives you a runtime test.

In VB, you can start a message loop via Application.Run. Before Run,
MessageLoop returns false, while the main form runs it returns true, and
during termination, it returns false. The moral is that you shouldn't cache
this boolean.

"D H" wrote:

> Is there anyway to tell from within your code, either at compile-time or
> run-time your assembly is running as a console app (exe) or windows gui
> app (winexe)?
>
> I wanted to for example create simple beep() and msgbox() functions that
> work differently in either mode.
>
>
.



Relevant Pages

  • Re: console app Q
    ... >> Is it possible to set the window title of a console app? ... > (ByVal lpConsoleTitle As String) As Boolean ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Sorting a System.Collections.ObjectModel.Collection
    ... Public Sub Dispose() Implements System.IDisposable.Dispose ... Private m_SupportsSorting As Boolean = True ... Protected Overrides ReadOnly Property SupportsSortingCoreAs Boolean ... Dim m_SortList As New ArrayList ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Sorting a System.Collections.ObjectModel.Collection
    ... Public Sub Dispose() Implements System.IDisposable.Dispose ... Private m_SupportsSorting As Boolean = True ... Protected Overrides ReadOnly Property SupportsSortingCoreAs Boolean ... Dim m_SortList As New ArrayList ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Can this be automated in the VBE?
    ... Function DB2SQLite(bNewFile As Boolean, strDB As String, _ ... strTable As String, strSQL As String, _ ... Optional strIndexFields As String, Optional bNoMessage As Boolean, _ ... Dim lRowCount As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: COM+, CRMs and Stuff
    ... Public Shared StartPath As String ... Public Sub New ... Dim _aRecord As New aRecord ... Function PrepareRecordAs Boolean ...
    (microsoft.public.dotnet.languages.vb)