Share via


CoreCon API – Part 1

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

Comments

  • Anonymous
    November 20, 2007
    PingBack from http://msdnrss.thecoderblogs.com/2007/11/20/corecon-api-part-1/

  • Anonymous
    November 21, 2007
    I do not have the Microsoft.Smartdevice.Connectivity.dll on my machine. Does it come with Device Emulator 3.0 or what? I have the folder (<systemdrive>:Program filesCommon FilesMicrosoft SharedCoreCon1.0Bin), but not the file-

  • Anonymous
    November 21, 2007
    you need Visual studio 2008 to use the new connectivity APIs (http://msdn2.microsoft.com/en-us/vstudio/default.aspx)

  • Anonymous
    December 07, 2007
    The Visual Studio for Devices team has been posting a very interesting and informative series on the

  • Anonymous
    December 07, 2007
    The Visual Studio for Devices team has been posting a very interesting and informative series on the

  • Anonymous
    December 10, 2007
    I have the dll in the correct folder, but when I run the above example, I get an error stating that the DatastoreManager could not be loaded from the dll.  What am I doing wrong?

  • Anonymous
    December 10, 2007
    Can you give us the specific error you are getting? In case you have 64 bit m/c please make sure that you compile for x86 (not any cpu).