Window title for console application
In the Connect to Visual Studio Process dialog box, one of the columns in the Available Processes list is Title, which contains the title of the topmost window that belongs to each process.
We create multiple instances of multiple backend processes to share the work. For these console processes, the Title field is empty, so we currently have to look for the process ID in our management tool to find the correct process.
To streamline the debugging process, I would like to be able to use the Title field to directly determine which process I want.
SetConsoleTitle doesn't do the trick, but SetWindowText with NULL hWnd. As far as I know, the console app doesn't have its own window handles that we could pass to SetWindowText. We don't want to create visible windows for these server processes.
Any suggestions for a sane way to trick Visual Studio into displaying useful information here?
a source to share
I think you might be out of luck. The console window is not related to the console process, but instead refers to the system process (conhost.exe on win7 and possibly vista, csrss.exe before that), so if Visual Studio is just looking for top-level process windows, t find the console window ... As far as I know, showing consoles from proc is not supported, so there is probably no sane way for visual studio to see the title of the console windows.
One possible solution would be to create a top-level window in your console process as a debugging tool. You might want to conditionally compile it, so it is only available when you are debugging. Just create an additional thread that pumps up messages and creates a top-level window. If you set the correct styles, the window will be invisible. You might not want to go with a window into the code, because in long server code, windows always increase your attack surface, even if only slightly.
This is probably not very useful, but it's worth mentioning that on Windows, the preferred way of doing partial work would be to use threads rather than multiple processes. A process is an expensive object, and threads are much cheaper in terms of system resources and also easier to debug.
a source to share