0

I have a Windows DLL library which can be used by different client applications, both GUI and console. Is there a way to find out programmatically the client application type? I am not interested in if there is actually a console attached or not.

Paavo
  • 111
  • 1
  • 10
  • 1
    Always avoid finding info the hard way when the client app can trivially tell you. – Hans Passant May 30 '14 at 13:51
  • Besides, the actual type of the executable may not accurately represent the way the executable is used, and any change in behaviour as a result may come as a very nasty surprise to the programmer. Consider, for example, a [GUI application whose debug build is a console executable](http://stackoverflow.com/a/23943220/886887). – Harry Johnston May 31 '14 at 09:52
  • Maybe I should have been less specific in my question, it seems this one is not so trivially answerable as I hoped. My real goal is to find out if e.g. stdout is in invalid state. In case of a console app the stdout is initialized correctly, whereas in a case of a GUI program stdout is left in an invalid state unless the application fixes it as per http://support.microsoft.com/kb/105305. The _get_osfhandle() function seems to return what appears to be an undocumented error code -2 for _fileno(stdout) if stdout is invalid, but as this is undocumented I am not sure how much I can rely on it. – Paavo Jun 01 '14 at 17:39

0 Answers0