Windows Mobile: Some logging tools
If you ever had a windows mobile device that behaved strange you might need some logging to find the cause.
Here is a collection of logging tools I wrote:
Windows Mobile Development and usage
Posts tagged ‘CodeProject’
If you ever had a windows mobile device that behaved strange you might need some logging to find the cause.
Here is a collection of logging tools I wrote:
PocketPC and Windows Mobile does not support a hosts file as desktop windows. As I recently had to add an entry for a virtual machine running Mini SAP (Netweaver 7.01 Trial) I stumbled about how to add a host entry to a windows mobile device.
The platform builder help gives the details about how host entries are organized:
The host name can be configured through the HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts subkey. When an application calls gethostbyname or getaddrinfo, the registry is queried first, before a DNS or WINS request is sent. If the host name is found in the registry, the registry values are returned.
The following table shows the values for the HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts\<Host Name> subkey.
Value : type | Description |
---|---|
Aliases : REG_MULTI_SZ | This value stores the aliases by which this host is known. |
ExpireTime : REG_BINARY | If the current time, obtained by calling GetCurrentFT, exceeds the value in ExpireTime, the entire Host Name subkey is deleted the next time that gethostbyname is called. The length of this value is 8 bytes. |
ipaddr : REG_BINARY | This value stores the IPv4 addresses associated with this host name. The length of this value is 4 bytes per address. |
ipaddr6 : REG_BINARY | This value stores the IPv6 addresses associated with this host name. The length of this value is 20 bytes per address (16 bytes for address and 4 bytes for Scope ID). |
So, there is no simple hosts file.
Continue reading ‘Mobile development: pocketHosts-Edit Windows Mobile hosts entries’ »
Recently I had to perform an automated stress test for a compact framework application using the camera. I remembered MortScript (original web site down) and wrote a script to automate the test.
Another way to run CLI apps and see there output is PocketConsole and PocketCMD. The original web site is down, so please use archive.org to get the files.
Now, as there are sometimes more needs to automate tests, for example for battery performance tests, I decided to mimic the motorola emScript environment. emScript offers a lot of functions you may need on other devices too. Instead of putting all functions into one executable, I decided to have extern command line driven tool set. So I started to develop small tools to perform device functions.
The first tool is scannerCLI. This tool issues a barcode scan on an intermec handheld device:
Just issue the scanner for a max time of supplied arg default timeout is 1 second: "ScannerCLI.exe x" will issue a barcode scan with a timeout of x seconds. x must be > 0 and < 10. "ScannerCLI.exe" will issue a barcode scan for max 1 second. The scan will be stopped immediately if a barcode is read. The return code is 0 for no barcode read, 1 for one or more read and negative for an error in barcode scan.
This tool is to control or query the backlight settings of intermec devices. As you know the backlight is one of the most battery consuming setting.
arguments function on switch backlight on using current brightness off switch backlight off max switch backlight brightness to max and on min switch backlight brightness to min and on state return 0 for is OFF, 1 for ON, -1 for error level return current brightness level or -1 for error 1 to max level set new brightness level, returns new level or -1 for error (ie val exceeds max level)
More tools will added here…
The source code for all published tools is be available at code.google.com.
http://code.google.com/p/win-mobile-code/source/browse/#svn%2Ftrunk%2Fcli-tools
Sometimes you may need to display a small window to inform the user about what is going on. Although the scripting tools MortScript and nScript provide functions to show dialogs they can not show simple information windows.
ShowWin is nothing special but a nearly full configurable window to be used from cmd line tools. It just uses Win32 API calls, constants and structures as FindWindow, PostMessage, SendMessage, WM_COPYDATA, COPYDATASTRUCT, GetSystemMetrics, GetDesktopWindow, GetWindowRect, CreateWindowEx, ShowWindow, UpdateWindow, INITCOMMONCONTROLSEX, GetDeviceCaps, CreateFontIndirect, GetWindowDC, ReleaseDC, PROGRESS_CLASS, InvalidateRect, BeginPaint, CreatePen, SelectObject, Rectangle, SetBkMode, DrawText, EndPaint, SetTextColor, DeleteObject, GetKeyState and PostQuitMessage.
Possibly you never wrote a native C windows application. Come on and dive into the basics. It is always good to know the basics even if one writes DotNet or JAVA code.
showWin -t "Text zum Anzeigen" -r 90 -g 80 -b 70 -s 8 -w 200 -h 50 -x 0 -y 0 -rt 200 -gt 20 -bt 20 -ti 10 -progr 30 -align left ARGS: option/parameter: meaning: default: limitations: -t "Text zum Anzeigen" text to show "Installing" 255 chars, no " inside, no line breaks, no tabs -r 90 background color RED 255 0-255 -g 80 background color GREEN 207 0-255 -b 70 background color BLUE 0 0-255 -s 8 font size in points 10 7-24 points -w 200 window width pixels 460 100-screenwidth -h 50 window height pixels 40 menu bar height (ie 26pixels) -x 60 window pos X 12 0 + system window bordersize -y 60 window pos Y 48 0 + system taskbar bar height. Using 0;0 does not work nice on WM, win may be below taskbar -rt 200 text color RED 0 0-255 -gt 20 text color GREEN 0 0-255 -bt 20 text color BLUE 0 0-255 -align center text alignment left center|left|right -ti 10 timeout to autoclose 0 no autoclose, min: 1 (second), max: 3600 = one hour -progr 10 show with progress val 0 no progressbar, max: 100 the progressbar is appended at bottom of textwindow -prval update progress bar value no default, min=1, max=100 -kill kill existing window, exit app -m "new message text" replace text in window see -t
Continue reading ‘Mobile development: show a small information window using WIN32 API’ »