GPS and the DeviceEmulator, Part 1 – emulated GPS without a GPS receiver

Have you ever wanted to run a GPS-aware application inside the DeviceEmulator, without using a hardware GPS receiver?  This would make both demos and test automation of GPS-aware applications much easier!

It turns out that the support is built right into Windows Mobile 5.0, both for the DeviceEmulator and for hardware PocketPCs.  The GPS Intermediate Driver can use a file as its data feed instead of a serial port.

Here is how:

  • Launch the Windows Mobile 5.0 PocketPC emulator

  • Use the Remote Registry Editor (in your PC's "Start\All Programs\Microsoft Studio 2005\Visual Studio Remote Tools") and connect to the Windows Mobile 5.0 PocketPC emulator

    • Navigate down into "HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers" 

    • Create a new value under "Drivers", with type REG_SZ, named "CurrentDriver", with value "FileDriver"

    • Add a new key under "Drivers", called "FileDriver".  Inside that key, add three values:

      • "InterfaceType" REG_SZ "File"

      • "FriendlyName" REG_SZ "File Driver"

      • "File1" REG_SZ "\gpsdata.txt"

  • Close the Remote Registry Editor.  The Windows Mobile 5.0 GPS Intermediate Driver is now configured to retrieve GPS NMEA data strings from a file named "\gpsdata.txt" instead of from a hardware GPS receiver.

  • Create \gpsdata.txt and populate it with NMEA data strings.  I used notepad on my PC to create a file containing the following data:

$PGRMM,WGS 84*06

  • Use the Remote File Viewer to copy that file into the emulator as "\gpsdata.txt"

Now, if you use a GPS-aware application, such as the sample in " C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket\PC SDK\Samples\Cs\Gps\Gps.sln", the application will report updated location information about once per second.

Here are links to relevant documentation:


Comments (8)
  1. IanBlackburn says:

    Hi Barry,

    I have had difficulty getting this to work (the emulator device state just stays on "Starting Up" using the sample code.

    However the reason I have been trying this is to resolve a bug I have found in the msdn code (:Program FilesWindows CE Toolswce500Windows Mobile 5.0 PocketPC SDKSamplesCsGpsGps.sln).  Further to my comment about a DivideByZero exception here : I have found a problem with the reported longitude when it is a fraction of 0 and west of the meridian (i.e. -0.0xxx) – these numbers are reported as positve by the code.  Once you move into then the longitude is reported correctly.

    I am struggling to work out why this is – any tips would be greatly appreciated.

    Ian Blackburn


    Microsoft Certified Partner | Mobility Solutions

  2. IanBlackburn says:

    Hi Barry,

    This is getting quite deep for a blog comment, but I think the problem is to do with the following method from the PocketPC GPS Sample code in the GPSPosition class:

    private DegreesMinutesSeconds ParseDegreesMinutesSeconds(double val)


    double degrees = (val / 100.0);

    double minutes = (Math.Abs(degrees) – Math.Abs((double)(int)(degrees))) * 100;

    double seconds = (Math.Abs(val) – Math.Abs((double)(int)val)) * 60.0;

    return new DegreesMinutesSeconds((int)degrees, (int)minutes, seconds);


    which turns a degree decimal from a gps reading to degree minutes and seconds.


    val = 1324.24 returns 12d 24m 34.79s


    24.24 return  0d 24m 34.79s

    The problem is when there is a negative val (e.g western longitude) with zero degrees.  E.g:

    -24.24 should return -0d 24m 34.79s but the above code would return 0d 24m 34.79s  ******because you can’t have a negative zero int*******.

    If the negative is 1 or larger there is no problem.  E.g.

    -124.24 gives -1d 24m 34.79s

    It’s late and there is not a clear answer for me here?  I must be missing something….

    Hope you can help…

  3. Barry Bond says:

    Ian, thanks for the feedback about the GPS sample – I have passed it along to the sample code owner.

    As for my instructions not working for you, I’ll reply them again on my machine and see if I missed a step when composing the blog.


  4. Barry Bond says:

    This blog:, talks about an important difference between GPS on the DeviceEmulator vs on hardware devices.

  5. LeonardoSalvatore says:

    I wroted an application that work directly on serial port with nmea protocol.

    I can change that to work with GPS ntermediate driver.

    what do you think?

  6. Guruman says:

    hi all,

    ok, i loaded the sample GPS application and ran it; all worked well…

    made a copy and then ‘upgraded’ the project to the v2.0 of .NET compact and now my form will not actually run properly in the emulator (form name not correct, controls not showing up, etc)… any thoughts?

    cheers and thanks in advance


Comments are closed.

Skip to main content