PDA

Ver la Versión Completa : UniqueID en PPC


samame
13-02-2007, 14:20:23
Saludos a todos, estoy tratando de identificar de forma única los PPC (PDA's). Vale, por ahora todo guay, he encontrado un codiguillo que me saca la MAC de un dispositivo FISICO, pero el problema lo tengo a la hora de sacar algo que me identifique de forma única el emulador de la PDA.

En esta página me dice cómo hacer para que la PDA se lo más real posible
http://blogs.msdn.com/vsdteam/archive/2005/10/07/478295.aspx
En esta otra me dice que ni de coña que se puede
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=9997&SiteID=1

Pero como todos nosotros somos algo cabezones, estamos ahí dale que te pego. Al final he declinado por tratar de sacar la MAC, pero necesito algo que sea único y me pueda identificar cada emulador.

Os dejo el código para sacar la MAC del dispositivo físico, por si alguien tiene este problema, pues solucionado.

Por cierto, estoy con C#, VS2005 y CF 2.0

private static Int32 IOCTL_HAL_GET_DEVICEID = ((FILE_DEVICE_HAL) << 16) | ((FILE_ANY_ACCESS) << 14) | ((21) << 2) | (METHOD_BUFFERED);

[DllImport("coredll.dll")]
private static extern bool KernelIoControl(Int32 IoControlCode, IntPtr
InputBuffer, Int32 InputBufferSize, byte[] OutputBuffer, Int32
OutputBufferSize, ref Int32 BytesReturned);


public static string GetDeviceID()
{
byte[] OutputBuffer = new byte[256];
Int32 OutputBufferSize, BytesReturned;
OutputBufferSize = OutputBuffer.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, OutputBuffer, OutputBufferSize, ref BytesReturned);

// If the request failed, exit the method now
if (retVal == false)
{
return null;
}

// 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(OutputBuffer, 4);
Int32 PlatformIDOffset = BitConverter.ToInt32(OutputBuffer, 0xc);
Int32 PlatformIDSize = BitConverter.ToInt32(OutputBuffer, 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(OutputBuffer, PresetIDOffset),
BitConverter.ToInt16(OutputBuffer, PresetIDOffset + 4),
BitConverter.ToInt16(OutputBuffer, PresetIDOffset + 6),
BitConverter.ToInt16(OutputBuffer, 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}", OutputBuffer[i]));
}

// return the Device ID string
return sb.ToString();
}

El problema está en que la llamada que hace al KernelIoControl devuelve false cuando estás con el emulador. Yo supongo que la constante
IOCTL_HAL_GET_DEVICEID llevará la información para decirle si es o no un emulador lo que se está manejando, pero... ahí me quedo.

Gracias a todos, ,un saludo.