Inside and Out…

An attempt to understand technology better…

Archive for August, 2005

Sharing Contacts from PocketPC – the vCard way

Posted by Gaurav Khanna on August 27, 2005

One of the features I miss in PocketPC is that of sharing contact details with other people without requiring to beam them off Bluetooth – basically meaning sending the data as a message to the recipient in question. A lot of other devices support such a functionality and I have had more than one occasion when I wished that such a feature was present in PocketPC device.

This lead me to explore on how to implement such a functionality and that too, in a standardized manner. This resulted me in looking up RFC 2426 (the spec. can be read here) – the vCard specification that allows us to share such information.

Soon, I was implementing a class library, vCardCE, for Windows Mobile 5.0 based PocketPC that allowed you to create a RFC 2426 compliant vCard:

  1. by setting few properties of the class, or
  2. by generating it from POOM Contact object – based out of Windows Mobile 5.0.

vCardCE currently supports the following attributes of RFC 2426:

  • Firstname
  • Middlename
  • Lastname
  • Home Address
  • Work Address
  • Title
  • Email Address
  • Photo (pointed via URL)
  • Website Address

The generated vCard is v3.0 compliant. Next, I wrote an application to share my contacts as vCard using vCardCE and came up with ShareContacts for PocketPC :

Tried and tested it with phones that understand vCard – and it works great to share contacts 🙂

You can download it from http://www.wintoolzone.com/showpage.aspx?url=dotnet.aspx. It requires Windows Mobile 5.0 based Pocket PC and .NET Compact Framework 2.0.

Posted in .NET Compact Framework, Downloads, Windows CE/Windows Mobile | Leave a Comment »

Enumerating Managed Processes

Posted by Gaurav Khanna on August 16, 2005

System.Diagnostics.Process class is a managed wrap over a subset of the ToolHelp API – as it enumerates only the process list. Not only that, it will list all the running processes, irrespective of whether they are running unmanaged code or running managed code. What if you wish to identify which of these processes are running managed code?

Unfortunately, neither the ToolHelp API, nor the Process class allow us to identify managed processes from the list they provide us. However, if you have noticed while debugging using Visual Studio, the debugger does identify a managed process in such a list:

VS debugger showing processes running managed code

So, how does the VS debugger do it?

Well, the CLR exposes debugging interfaces, which contain this functionality. These interfaces include ICorPublish, ICorPublishProcess, ICorPublishAppDomain, just to name a few. Infact, if you have installed the .NET Framework 2.0 SDK and navigate to the %SDKRoot%\v2.0\include folder, you will see the relevant header files that contain these interface definitions

The same identification can now also be done using managed code. Under %SDKRoot%\v2.0\bin folder, you will find, amongst others, MdbgCore.dll – the core of the managed debugger. If you ILASM this file (yes, its an assembly), you will see the managed wraps of the unmanaged interfaces mentioned above:

Managed wraps of the unmanaged interfaces

The starting point is Microsoft.Samples.Debugging.CorPublish.CorPublish. This lets us enumerate the managed processes, returning an instance of Microsoft.Samples.Debugging.CorPublish.CorPublishProcess type. Below is a sample that exemplifies doing the same:

using
System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Samples.Debugging.MdbgEngine;
using Microsoft.Samples.Debugging.CorPublish; namespace ManagedProcessList
{
    class Program
    {
        static void Main(string[] args)
        {
            CorPublish pub = new CorPublish();
            foreach (CorPublishProcess proc in pub.EnumProcesses())
            {
                Console.WriteLine(“{0} IsManaged: {1}”, proc.DisplayName, proc.IsManaged.ToString());
            }
        }
    }
}

Posted in .NET Framework, Debugging, Tips | Leave a Comment »