ユニークなIDを取得する
ここらを参考に。Sigmarion3ではUUIDの方を取得しろとのことなので。
using System;
using System.Runtime.InteropServices;
public class Sigmarion3
{
private static Int32 FILE_DEVICE_HAL = 0x00000101;
private static Int32 FILE_ANY_ACCESS = 0x0;
private static Int32 METHOD_BUFFERED = 0x0;
private static Int32 IOCTL_HAL_GET_UUID =
((FILE_DEVICE_HAL) << 16) | ((FILE_ANY_ACCESS) << 14) | ((13) << 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 byte[] GetID()
{
byte[] OutputBuffer = new byte[16];
Int32 OutputBufferSize, BytesReturned;
OutputBufferSize = OutputBuffer.Length;
BytesReturned = 0;
bool retVal = KernelIoControl(IOCTL_HAL_GET_UUID, IntPtr.Zero, 0, OutputBuffer, OutputBufferSize, ref BytesReturned);
if (!retVal)
{
return null;
}
return OutputBuffer;
}
}
エミュレータだと取得に失敗するなぁ。実機ならおk
Leave a Reply