Archive for September, 2008

Run Command Prompt on a Mobile Device

The Command Prompt is not available on a Windows Mobile device out-of-the-box. So if you want to do some command-line compiling or registering a DLL on the mobile device you’ll have to install the PPC Command Shell Power Toy. You can download it here. Follow the instructions in the ReadMe file to set it up.

PPC Command Prompt

PPC Command Prompt


However, a few of my colleagues have come across the following problem:

When you double-click the cmd.exe on the mobile device, it does not launch the Command Prompt window.

The solution was quite simple yet hard to find. Edit the mobile device’s Registry and change the OutputTo DWORD value to “0″ under the HKEY_LOCAL_MACHINE \ Drivers \ Console folder.

Editing the Registry

Editing the Registry

If you have Visual Studio 2005 installed, you can access the Remote Registry Editor under Visual Studio Remote Tools. Or there are a bunch of Registry Editors out there for mobile devices that you can use e.g. CeRegEditor and PHMRegEditor.

Enable FILECTL ActiveX component on Mobile Devices

Earlier I wrote about how you could use the FILECTL component to write files on a mobile device.

A few people emailed me to tell me that they were getting the “ActiveX cannot create object CreateObject” error. So this time I’m going to go into more detail about how you first prepare the mobile device before you can use the FILECTL component.

Let’s get to it:

  1. Download and copy the regsvrce.exe and MSCEFile.dll to the /Windows folder on the device. There are a couple of different versions of MSCEFile.dll out there, make sure you have the correct one based on your device OS\version.
  2. Enable Command Prompt on the device. You can download the PPC Command Shell powertoy to do this.
    NOTE: If you keep double-clicking the cmd.exe and nothing happens, here’s what you do:
    a. Access the Registry and change the “OutputTo” DWORD value to 0 (zero) under HKEY_LOCAL_MACHINE\Drivers\Console.
  3. Launch the Command Prompt window, and type “regsvrce.exe MSCEFile.dll” and press Enter.
  4. A pop-up message will appear saying the DLL was registered successfully.
  5. You’re done!

Now run your VBScript again and it should not throw any CreateObject-related errors.

Writing Files on a Mobile Device using FILECTL

If you want to write files on a mobile device, this can be easily accomplished using a little VBScript.

I was trying to use the FileSystemObject component to write files. However, the file storage component is managed differently on PocketPC 2002/03, Windows CE 4.2 (and above) devices such as the HP iPAQ, Symbol 9090 etc. Instead of FileSystemObject, the FILECTL component needs to be called. FileCtl is the FSO equivalent for Windows CE.

Following is the VBScript code:

Dim objTextFile, strText
strText = “This is my string of data”

‘ objTextFile.Open needs the following Const values:
‘ ForAppending, fsAccessWrite, fsLockReadWrite
Const ForAppending = 8
Const fsAccessWrite = 2
Const fsLockReadWrite = 0

Const objFilePath = “\Temp\MyFile.txt”

Set objTextFile = CreateObject(“FILECTL.File”)
objTextFile.Open objFilePath, ForAppending, fsAccessWrite, fsLockReadWrite

‘ Writes strText every time you run this VBScript
objTextFile.LinePrint(strText)

objTextFile.Close
set objTextFile = nothing

For reference, you can go to:  http://msdn2.microsoft.com/en-us/library/ms860108.aspx

If you know of a better way accomplishing this, feel free to share!

Generating the WSDL before writing your Web Service

A lot of projects that I have worked on required me to provide the Web Service Definition Language (WSDL) file way before I was done writing the Web Service. Reason being that the WSDL file acts like a contract between the two communicating parties. This contract allows rapid development as one team is not waiting on the other to move forward.

thinktecture has an absolutely fantastic tool to do this. I use thinktecture’s WSCF – Web Services Contract First plugin for Visual Studio 2005 on a regular basis now and the documentation is very helpful to get you up and running in a jiffy.

Brief description of WSCF from thinktecture’s website:

WSCF offers a simple yet powerful WSDL Wizard that abstracts away all the nitty-gritty details of WSDL and therefore does not give room for making errors and wrong assumptions just by trying to use and applying everything that can be done stated by the original WSDL specification.

You can find it here: http://www.thinktecture.com/resourcearchive/tools-and-software/wscf

Thanks thinktecture!

Hello!

Welcome to SandboxM.com!