Click here to Skip to main content
15,903,012 members

Comments by wvd_vegt (Top 9 by date)

wvd_vegt 4-Mar-13 3:47am View    
Reason for my vote of 1 \n Why advertise what seems your own (commercial) product here on codeproject?
wvd_vegt 22-Nov-12 9:02am View    
Reason for my vote of 4
Simple but not enough to debug all services. If a service runs under for instance a service account, temporary directories are located elsewhere. Same for a current (or other) directory, they might not be writable (which can cause nasty problems with features logging).
wvd_vegt 25-Mar-12 14:23pm View    
Reason for my vote of 1
Just trying comport numbers is not the correct way. The SerialPort class has an enum containing the available ports. Furthermore may ports above 9 need a special name prefix of \\?\.
Better is to retrieve the friendly device names and make a correct choice rigth away (especially for usb serial ports that tend to switch places the friendly name is a good choice most of the time).
wvd_vegt 8-Feb-12 6:04am View    
Deleted
Hi

You can (early in your program) implement a ConsoleTraceListener so you can divert the Console output to your own routines (like a winform+textbox). The same is available for Debug.WriteLine if i'm correct. In such handler you could buffer the messages until a form particular winform is shown.

As for the Console API can be found at http://msdn.microsoft.com/en-us/library/ms682087(VS.85).aspx. In a ConsoleTraceListener you should use methods like WriteConsole to really access the Console. The Api also allows for coloring text ect. Removing the close button is very tricky

My console code is around 56kb including pinvoke signatures so yes the api is complex.

Some handy snippets:

1) Find the console window:

while (fHandle == IntPtr.Zero)
{
if (fHandle == IntPtr.Zero)
{
//win32 aka winnt4/w2k/winxp/vista/win7
fHandle = FindWindow("ConsoleWindowClass", Caption);
}

if (fHandle == IntPtr.Zero)
{
//win98 window class
//win98 is also much slower
fHandle = FindWindow("tty", Caption);
}

//and shows CONSOLE as caption first.
if (fHandle == IntPtr.Zero)
{
fHandle = FindWindow("tty", "CONSOLE"); //win98 window class
}
};

2) Remove the Close button:

ShowWindow(fHandle, (Int32)SW.Hide); //winnt4
RemoveMenu(GetSystemMenu(fHandle, false),
(uint)SC.CLOSE,
(uint)MF.BYCOMMAND);
ShowWindow(fHandle, (Int32)SW.Show); //winnt4
wvd_vegt 8-Feb-12 4:20am View    
Deleted
Hi
You're clearly doing something wrong (like using Console.Writeline). I have since ages a console window under a menuitem and it works like charm if you use the win32 api to write and take precautions on the close box & system menu items + ctrl-c/break handling.