Get Device ID from Desktop

Hi All,

First of all, I would like to apologize if this is not the right forum to post this type of question. I have tried to post it in .NET Networking & Compact Framework section, but there were no replies.

I would like to create an application that reside in desktop side, that is capable to get the device id from the PDA through ActiveSync.

I have been able to retrieve the id through P/Invoke (KernelIoControl) if the process is executed inside the PDA. However, it has been a lot of difficulties once I try to do it through desktop.

I read about RAPI, and found that there is an unmanaged call from ceutil.dll (CeGetDeviceId) that is capable to retrieve the id of the device. However, I'm not sure if the retrieved id is similar to the one that is through KernelIoControl.

Besides, I found difficulty in terms of calling this function from C#.

Can anyone help me with this calling issue Has anyone ever P/Invoke this function before from C#

Thank you.



Answer this question

Get Device ID from Desktop

  • Mahesh B. Mane

    platform invoke makes it easy.
  • chubalot

    have you tried this:

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/wceappenduser5/html/wce50oriactivesync.asp

    you can get the GUID as shown in the Activesync Functions however I am unsure if this is from the desktop or the mobile device.



  • AAx

    Hendro Wijaya wrote:

    Hi,

    Thanks for the replies.

    Can you please show me a sample of it

    http://msdn2.microsoft.com/en-us/library/ms172516(VS.80).aspx


  • emman101

    Hi Hendro,

    I'm building a desktop application. When a mobile device is put in the cradle, i get a connected event and through rapi i can do stuff.

    Now my problem is to get the device ID from the connected device.

    The only way i can get the ID now is to run a program on the device that gets the deviceID.

    i tried this: http://blog.opennetcf.com/ncowburn/2007/07/27/HOWTORetrieveTheDeviceIDFromTheDesktop.aspx

    but i can't get a good working dll.. or my invoke doesn't work, but i never get a result back from it..

    In your solution, do you use the desktop app to copy the console program to the device and then also run it Do you have an example app or some code about how i can do that

    You can also mail it to dekkererik@hotmail.com if you have something what can help me..

    Any help would be great.. i don't really know what to do anymore now.

    Thanks!

    Greetings, Erik


  • Whatabohr

    You'd need to create native DLL (in C/C++) which does what you need and is designed to be invoked by RAPI.

    That DLL would run on device so you can use technique described above, but result would be available to desktop.

    To get ID please do that:

    1. Copy DLL which gets ID on to the device using RAPI's CeCopyFile().

    2. Invoke this DLL using RAPI's CeRapiInvoke().



  • fooguru

    I think it's called GUID. I looked at it, and it's about 32-digits hexa value.

    Yes, I meant get the PDA's GUID from the application that is reside in desktop side (through ActiveSync).

    Thanks for the replies


  • davidc20

    Hi,

    Thanks for the replies.

    Can you please show me a sample of it


  • David.Dong

    Can you please clarify what you mean by "device ID"

    do you mean:

    Device -> desktop partnership in activesync

     

     



  • Paul Curtis

    Hi Andrew,

    Thanks for the replies.

    That was what I did with "get the id from inside the device itself". This way, I would assume that the process need to be deployed into the system in order to run it.

    What I would like to achieve is, "get the id from outside the device (from desktop)". Therefore, the process is cleaner in the sense, I don't need to deploy anything into the user's device.

    The scenario is: I have one PDA and one application that is run in desktop (.NET Framework). Before we start installing all the process, we would like to retrieve the id from PDA and somehow compare with our database. I wish to be able to retrieve the id from RAPI (ActiveSync) using C#.

    Any replies are highly appreciated. Thank you.


  • Kedrik

    Hi All,

    Thanks for the replies.

    The way that I am doing it is very close to the Ilya suggestion. Instead of using DLL, I am using the console program that is written specifically to retrieve the ID and store it in registry.

    First, I check the registry to see if the id is exist. If not, then I will copy the program across, run the process and delete it.

    Then, the desktop will only need to re-query the registry to get the id.

    Hope it helps for other people who come across the same problem.


  • Get Device ID from Desktop