Mobile Developement – RDP AutoLogin extended (version 4)

Print This Post Print This Post

Hello

on the wish of the one or other user I extended the RDP AutoLogin code and we now reached level 4.

The new code simply has only one extension, it supports the color depth selection. Also the color depth and other settings are visible on the dialog of Remote Desktop Mobile, the settings itself are done via the Default.rdp file. But you are right, RDP_AutoLogin also controls some of the dialog items directly.

[codesyntax lang="text"]

...
Domain:s:
ColorDepthID:i:3
ScreenStyle:i:0
DesktopWidth:i:640
DesktopHeight:i:480
UserName:s:rdesktop
...
ServerName:s:192.168.128.5
SavePassword:i:1
...

[/codesyntax]

The color depth setting supports two modes, 8 Bit with 256b colors (ColorDepthID:i:1) and 16 Bit with ~65000 colors (ColorDepthID:i:3).

[codesyntax lang="reg"]

REGEDIT4

[HKEY_LOCAL_MACHINE\Software\RDP_autologin]
"FitToScreen"="1"
"FullScreen"="1"
"Status"="connecting..."
"Save Password"="1"
"Domain"=""
"Password"="Intermec+2004"
"Username"="rdesktop"
"Computer"="192.168.0.130"
"DesktopWidth"=640
"DesktopHeight"=480
"startOnExit"="\\rdp_keepBusy.exe"
"execargs"="noRDPstart"
"UseMouseClick"="0"	//added with version 3 to switch between mouse and keyboard simulation
"ColorDepth"=1		//added with version 4 to enable switching between 8 and 16 Bit colors

[/codesyntax]

The code changes are small. Some code addition to read the value from the registry and some to write the rdp file:

[codesyntax lang="cpp"]

void readReg(){
...
        //ColorDepth new with version 4
        if(RegReadDword(L"ColorDepth", &dwTemp) == 0)
            dwColorDepth=dwTemp;
...
}
void writeRDP(){
...
			else if(wcsstr(rdpLines[c].line, L"ColorDepthID")!=NULL){
				wsprintf(szTemp, rdpLines[c].line, dwColorDepth);  //3=HighColor(16Bit) or 1=(8Bit) color
			}
...
}

[/codesyntax]

Additionally I have added a new project to the solution to enable to set all the settings not only via the registry but using a GUI application. RDP_Autologin_Settings is born:

 

As you see, there is also a small file browser integrated. The default OpenFile dialog of Compact Framework does not allow you to browse all directories, but only “\My Documents”.

RDP AutoLogin Settings Editor (exe): DOWNLOAD:RDP AutoLogin Settings editor - (Hits: 492, size: 10.45 kB)
source (Visual Studio 2008 WM5 SDK project): DOWNLOAD:RDP AutoLogin Settings editor Source Code - (Hits: 304, size: 21.23 kB)

RDP_AutoLogin (exe): DOWNLOAD:RDP AutoLogin Executable - (Hits: 455, size: 6.78 kB)
source (Visual Studio 2008 WM5 SDK project): DOWNLOAD:RDP AutoLogin Source Code - (Hits: 301, size: 56.85 kB)

RDP_KeepBusy (exe): DOWNLOAD:RDP KeepBusy (executable) - (Hits: 397, size: 3.17 kB)
RDP_KeepBusy (vs2008 WM5 SDK project): DOWNLOAD:RDP KeepBusy Source Code - (Hits: 280, size: 12.92 kB)

Have fun

Josef

4 Comments

  1. [...] on version-4 here is an more extended version with the option to preset Resource mapping (Device storage and [...]

  2. Olaf says:

    Hallo Josef,

    thank you for your great site to better understand RDP for WM6.x. You handle autologin and keep a RDP session alive. I am struggling with nearly the opposite problem. I start RDP client calling wpctsc.exe under the control of a local .NET-CF application. My local and remote application communicate via clipboard. That works fine. The problem: My local application does not recognize, when remote application and therefore RDP session is closed, because the wpctsc application keeps runnig with login screen. Even the “X” button doesn´t really terminates the wpctsc program. (I don´t understand that WM “feature”, to keep closed applications alive.)

    Before I had to switch to RDP, I had done the same job with citrix client. That client really terminates after use.

    Do you have any hint, how I can recognize, that wpctsc is finisched (and maybe the user pressed the X button on login screen)?

    Viele Grüße!
    Olaf

  3. admin says:

    Hello

    you may simply check the window state of wpctsc window or the window title. If in start screen, the window class “TSSHELLWIN” has the window title “Remote Desktop Mobile”. The window title will change when RDM is connected. You need to pinvoke FindWindow() and GetWindowText().

    A tool to look for window titles is RemoteSpy by MS or WinTreeCE.

    ~josef

  4. Olaf says:

    Hello Josef,

    my summary: wpctsc is not very amusing.

    But with your help and the following way I could find the login screen, send a close (pinvoke of SendMessage). Afterwards a process wpctsc.exe has been left. I kill that one and my application is happy.

    //find and close window
    IntPtr ptr = FindWindow(null, “Remote Desktop Mobile”);
    if (ptr != IntPtr.Zero)SendMessage(ptr, WM_CLOSE, 0, 0);

    For finding the process I used a third party api, because I couldn´t find a built-in GetProcessesByName
    I killed the process with Process.Kill().

    Uncomfortable: Starting the client, the window title is “Remote Desktop Mobile”, too. So I have to wait a bit before I close it in order to allow the user to login to the ts server.

    Olaf

Leave a Reply