VSD is shipping Set of connectivity API which could be used to write remote tools (Remote file viewer etc) kind of Apps. This series of blog is aimed at giving an introduction about the connectivity APIs.

 

Datastore is a set of XML files on your desktop computer that contains information about the platforms, devices, emulators, and packages that are installed on the computer. The contents of the Datastore are modified whenever you install an SDK that is based on Windows CE such as Windows Mobile.  Let’s start with an app which looks at the datastore and enumerate list of SDKs and devices installed in the machine.

[Create a new C# Desktop console application. Add reference to Microsoft.Smartdevice.Connectivity.dll which can be found at <systemdrive>:\Program files\Common Files\Microsoft Shared\CoreCon\1.0\Bin ]

 

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SmartDevice.Connectivity;

using System.Collections.ObjectModel;

 

namespace sample1

{

    class Program

    {

        static void Main(string[] args)

        {

            //Instead of 1033 use the locale ID of your app.

            DatastoreManager dsmgrObj = new DatastoreManager(1033);

 

            //Get all the platform entries present in Data store

            //Iterate through Collection of platforms

            Collection<Platform> platformCollection = dsmgrObj.GetPlatforms();

            foreach (Platform objplatform in platformCollection)

            {

                System.Console.WriteLine(objplatform.Name);

                Collection<Device> deviceCollection = objplatform.GetDevices();

                //List all the devices in the platform

                foreach (Device objdevice in deviceCollection)

                {

                    System.Console.WriteLine("\t" + objdevice.Name);

                }

            }

 

        }

    }

}

 

Let’s look at some options to connect to a device and get info regarding the device.

In the below sample I am connecting to PPC 05 emulator and getting info regarding virtual and physical memory. IDs of devices/SDK can be obtained from the datastore files which can be found in

<sysDrive>:\Documents and Settings\<username> \Local Settings\Application Data\Microsoft\CoreCon\1.0 (Non Vista OS) or <sysDrive>:\users\<username>\Application data\Microsoft\CoreCon\1.0 (Vista)

 

Open the conman_ds_platform.xsl file in visual studio. This file contains the information about all the installed SDKs.

 

DatastoreManager dsmgrObj = new DatastoreManager(1033);

 

ObjectId ppc05PlatObjID = new ObjectId("4118C335-430C-497f-BE48-11C3316B135E");

ObjectId PPC05EmuID = new ObjectId("25D984D9-0DFE-4DB1-A5A0-9A4F660BF2CE");

 

Platform ppc05Plat = dsmgrObj.GetPlatform(ppc05PlatObjID);

Device ppc05Emu = ppc05Plat.GetDevice(PPC05EmuID);

 

//Connect to the device.

ppc05Emu.Connect();

SystemInfo pp05EmuInfo = ppc05Emu.GetSystemInfo();

System.Console.WriteLine("Available Physical Memoory\t:\t"+pp05EmuInfo.AvailPhys);

System.Console.WriteLine("Total Physical Memoory    \t:\t" + pp05EmuInfo.TotalPhys);

System.Console.WriteLine("Available Virtual Memoory \t:\t" + pp05EmuInfo.AvailVirtual);

System.Console.WriteLine("Total Physical Memoory    \t:\t" + pp05EmuInfo.TotalVirtual);

System.Console.WriteLine("OS Major number           \t:\t" + pp05EmuInfo.OSMajor);

System.Console.WriteLine("OS Minor number           \t:\t" + pp05EmuInfo.OSMinor);

 

--

Anand R