views:

51

answers:

1

How can I tell whether the user launched my console application by double-clicking the EXE (or a shortcut), or whether they already had a command line window open and executed my console app within that session?

A: 

You might be able to figure it out by P/Invoking to the Win32 GetStartupInfo() function.

[DllImport("kernel32", CharSet=CharSet.Auto)]
internal static extern void GetStartupInfo([In, Out] STARTUPINFO lpStartupInfo);
Mark Cidade