Hi guys,
I wrote a simple rdp App with C#, i'am using MSTSCLIB. This works fine for me.
this.FormBorderStyle = FormBorderStyle.None;
rdp.Server = "*********";
rdp.UserName = "*********";
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = "***********";
rdp.DesktopHeight = 1080;
rdp.DesktopWidth = 1920;
rdp.AdvancedSettings8.AuthenticationLevel = 2;
rdp.Connect();
Sometimes the user is allready logged on to the remote workstation and I receive a Windows Dialog "The specified Windows account is already logged in. ...".
I need help with a solution to confirm that Windows dialog automatically.
What I have tried:
So the first idea was to set the application in foreground:
Process processes = Process.GetCurrentProcess();
IntPtr windowhandle = processes.MainWindowHandle;
SetForegroundWindow(windowhandle);
And the second step is to get the windows Handle ID with spy++ and use FindWindow() to use SendMessage() to close the MessageBox Handle.
IntPtr handle = FindWindow("?????????", null);
MessageBox.Show("Hanlde1: " + handle.ToString() + "\n");
IntPtr txtHandle = FindWindowEx(handle, IntPtr.Zero, "Static", null);
MessageBox.Show("\ttext handle: " + txtHandle.ToString() + "\n");
int len = GetWindowTextLength(txtHandle);
StringBuilder sb = new StringBuilder();
GetWindowText(txtHandle, sb, len + 1);
MessageBox.Show("\ttext: " + sb.ToString() + "\n\n");
SendMessage(new HandleRef(null, handle), WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
So my problem is, that I can't get the Handle ID from spy++ for the Dialog in the RDP connection. It shows me only the ID from the parent Window not from the Windows Dialog.
So my first question is: Is that the correct way to handle this dialog window? And Second Question: How can I receive the correct Handle ID of the Dialog Window in the RDP Session.
Many Thanks.
Hagen