Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8316495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:22:36+00:00 2026-06-08T21:22:36+00:00

When I connect to a windows mobile device from the PC using the RAPI

  • 0

When I connect to a windows mobile device from the PC using the RAPI API I can get its device ID like so:

using (RemoteDeviceManager r = new RemoteDeviceManager())
{
     using (RemoteDevice dev = r.Devices.FirstConnectedDevice)
     {
         //dev.DeviceId; <--the id
     }
}

How can I get the same ‘DeviceId’ value on the device itself in compact framework?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:22:37+00:00Added an answer on June 8, 2026 at 9:22 pm

    Microsoft published a library article back in 2003 on Retrieving the Windows CE Device ID with the Microsoft .NET Compact Framework that I have been using with success.

    [DllImport("coredll.dll")]
    private static extern bool KernelIoControl(Int32 IoControlCode, IntPtr InputBuffer, Int32 InputBufferSize, byte[] OutputBuffer, Int32 OutputBufferSize, ref Int32 BytesReturned);
    
    private static string GetDeviceID() {
      // Reference: http://msdn.microsoft.com/en-us/library/aa446562.aspx
      byte[] data = new byte[256];
      Int32 OutputBufferSize, BytesReturned;
      OutputBufferSize = data.Length;
      BytesReturned = 0;
      // Call KernelIoControl passing the previously defined IOCTL_HAL_GET_DEVICEID parameter
      // We don’t need to pass any input buffers to this call
      // so InputBuffer and InputBufferSize are set to their null values
      bool retVal = KernelIoControl(IOCTL_HAL_GET_DEVICEID, IntPtr.Zero, 0, data, OutputBufferSize, ref BytesReturned);
      // If the request failed, exit the method now
      if (retVal) {
        // Examine the OutputBuffer byte array to find the start of the 
        // Preset ID and Platform ID, as well as the size of the PlatformID. 
        // PresetIDOffset – The number of bytes the preset ID is offset from the beginning of the structure
        // PlatformIDOffset - The number of bytes the platform ID is offset from the beginning of the structure
        // PlatformIDSize - The number of bytes used to store the platform ID
        // Use BitConverter.ToInt32() to convert from byte[] to int
        Int32 PresetIDOffset = BitConverter.ToInt32(data, 4);
        Int32 PlatformIDOffset = BitConverter.ToInt32(data, 0xc);
        Int32 PlatformIDSize = BitConverter.ToInt32(data, 0x10);
    
        // Convert the Preset ID segments into a string so they can be 
        // displayed easily.
        StringBuilder sb = new StringBuilder();
        sb.Append(String.Format("{0:X8}-{1:X4}-{2:X4}-{3:X4}-",
             BitConverter.ToInt32(data, PresetIDOffset),
             BitConverter.ToInt16(data, PresetIDOffset + 4),
             BitConverter.ToInt16(data, PresetIDOffset + 6),
             BitConverter.ToInt16(data, PresetIDOffset + 8)));
    
        // Break the Platform ID down into 2-digit hexadecimal numbers
        // and append them to the Preset ID. This will result in a 
        // string-formatted Device ID
        for (int i = PlatformIDOffset; i < PlatformIDOffset + PlatformIDSize; i++) {
          sb.Append(String.Format("{0:X2}", data[i]));
        }
        // return the Device ID string
        return sb.ToString();
      }
      return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how i can print from ppc (windows mobile) to usb printer that connect to
I'm using TCP/IP over ActiveSync to connect from Windows CE device to Windows XP
How can i connect a windows phone 7 device with a WiFi-enabled micro controller.
I am using IPython 0.12.1 notebook to connect from a Windows machine to a
So I am fairly new to ASP.NET MVC and Windows Live Connect API. Basically
How can I connect to a MySQL database from Windows Forms?
I'm looking for a way to connect a Windows Mobile device to a PC
I'm trying to connect from a pocket pc app (windows mobile 6) to a
I connect my windows mobile app directly to ms-sql server using the sqlclient dll
I'm trying to connect from my ms windows 7 via the odbc administrator to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.