Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / All-Topics

Automated Login for Remote Desktop Mobile II

0.00/5 (No votes)
4 May 2010CPOL 9K  
Tool to have Remote Desktop Mobile login automatically to a terminal server

Some days ago, I published my RDP_Autologin code: RDP_Autologin

As there were some screen metrics hardcoded and more and more devices come with a VGA screen, the hardcoded QVGA values will not match. So I extended the first version and implemented some additional logic and settings.

First, the emulated screen tap has been adjusted to depend on the device screen width and height. For that, I included the HIRES_AWARE resource to get the real screen size.

...
	DWORD dX = (0xFFFF / iScreenWidth) * (80); // changed from 13 to width=240, 1/3=80
	DWORD dY = (0xFFFF / iScreenHeight) * (iScreenHeight - 13);
...
BOOL getScreenSize(){
	int iScreenX = GetSystemMetrics(SM_CXSCREEN);
	int iScreenY = GetSystemMetrics(SM_CYSCREEN);
	DEBUGMSG(1, (L"\ngetScreenSize: x=%i, y=%i\n", iScreenX, iScreenY));
	if(iScreenX>0)
		iScreenWidth=iScreenX;
	if(iScreenY>0)
		iScreenHeight=iScreenY;
	if(iScreenX+iScreenY > 0){
		_itow(iScreenWidth, sScreenWidth, 10);
		_itow(iScreenHeight, sScreenHeight, 10);
		return TRUE;
	}
	else
		return FALSE;
}
...

The rdp file defaults for desktop width and height will also be calculated but you can set the default to use via the registry.

C++
REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\RDP_autologin]
"startOnExit"="\\rdp_keepbusy.exe"
"DesktopHeight"=dword:000001E0
"DesktopWidth"=dword:00000280
"Computer"="192.168.0.2"
"FitToScreen"="0"
"FullScreen"="0"
"Username"="rdesktop"
"Password"="xxxx"
"Domain"=""
"Save Password"="1"
"Status"="connecting..."

As you can see, I added a line where you can specify an application that will be started at the end of the autoconnect process: startOnExit.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)