How to determine console or winform app?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • None

    How to determine console or winform app?

    Hello, my app is written in C#. Given an app file path (e.g. e:\abc.exe),
    how can I determine if it's a winform app or a console one. (note: abc.exe
    can be either a native exe or a .net one)


  • kimiraikkonen

    #2
    Re: How to determine console or winform app?

    On May 11, 4:43 pm, "None" <n...@none.comw rote:
    Hello, my app is written in C#. Given an app file path (e.g. e:\abc.exe),
    how can I determine if it's a winform app or a console one. (note: abc.exe
    can be either a native exe or a .net one)
    Hi,
    Try to run the application from command prompt (cmd.exe) then if it's
    a winform application the application's main form is opened as window,
    if not, the program is started and output is visible inside command
    prompt as just a guess to verify, better ideas may exist.

    Thanks,

    Onur Güzel

    Comment

    • Paul E Collins

      #3
      Re: How to determine console or winform app?

      "None" <none@none.comw rote:
      Hello, my app is written in C#. Given an app file path (e.g.
      e:\abc.exe), how can I determine if it's a winform app or a console
      one. (note: abc.exe can be either a native exe or a .net one)
      You will need to study the Portable Executable (PE) file format.

      Then you can open the .exe file with a BinaryReader and pick out the
      information you need.

      Eq.


      Comment

      • Peter Duniho

        #4
        Re: How to determine console or winform app?

        On Sun, 11 May 2008 06:43:31 -0700, None <none@none.comw rote:
        Hello, my app is written in C#. Given an app file path (e.g. e:\abc.exe),
        how can I determine if it's a winform app or a console one. (note:
        abc.exe
        can be either a native exe or a .net one)
        One way would be to use the "Debug Help" library
        (http://msdn.microsoft.com/en-us/libr...9(VS.85).aspx). You can
        use the ImageNtHeader() function to retrieve the PE headers for the
        executable, and then check the subsystem information to see whether it's
        GUI or command-line.

        Note that a console application can in fact create a GUI. It's not really
        clear why you're trying to do this, but keep in mind that you may or may
        not be able to reliably accomplish your goal, depending on what
        applications you're dealing with and why you really want to know whether
        they are console or GUI.

        Pete

        Comment

        • None

          #5
          Re: How to determine console or winform app?

          thanks. I am looking into the pe file format.


          "Paul E Collins" <find_my_real_a ddress@CL4.orgw rote in message
          news:qbSdnYbjK9 rewrrVRVnygQA@b t.com...
          "None" <none@none.comw rote:
          >
          >Hello, my app is written in C#. Given an app file path (e.g. e:\abc.exe),
          >how can I determine if it's a winform app or a console one. (note:
          >abc.exe can be either a native exe or a .net one)
          >
          You will need to study the Portable Executable (PE) file format.

          Then you can open the .exe file with a BinaryReader and pick out the
          information you need.
          >
          Eq.
          >
          >

          Comment

          • Mike Blake-Knox

            #6
            Re: How to determine console or winform app?

            In article <op.ua0jpbjz8jd 0ej@petes-computer.local> , Peter Duniho
            wrote:
            Note that a console application can in fact create a GUI.
            Which means a specific executable can be BOTH a console application and
            a GUI application.

            Mike

            Comment

            • Peter Duniho

              #7
              Re: How to determine console or winform app?

              On Wed, 14 May 2008 03:51:04 -0700, Mike Blake-Knox
              <mikebk@communi ty.nospamwrote:
              In article <op.ua0jpbjz8jd 0ej@petes-computer.local> , Peter Duniho
              wrote:
              >Note that a console application can in fact create a GUI.
              >
              Which means a specific executable can be BOTH a console application and
              a GUI application.
              Well, that all depends on your definition of "GUI application". That's
              true from a behavioral point of view, but it's not true from a PE
              configuration point of view.

              We don't have any information from the OP that would help us understand
              why he wants this information at all, never mind which is the more
              appropriate definition. :)

              Pete

              Comment

              Working...