|
Prev: CREATEPROCESS and EXITPROCESS
Next: Date?
From: A_PK on 22 Feb 2005 20:22 How can I read the device ID ? my application wanna show the pocket pc device ID. how to write a code to read the device id ?
From: Tim Wilson on 22 Feb 2005 23:54 There is a lot of information about this topic. One blog entry that you might want to read is here (http://blogs.msdn.com/jehance/archive/2004/07/12.aspx). And if you still have questions then you might want to look through the other posts on this subject. http://groups-beta.google.com/groups?as_q=device+id&num=10&as_ugroup=microsoft.public.dotnet.framework.compactframework http://groups-beta.google.com/groups?as_q=device+id&num=10&as_ugroup=microsoft.public.pocketpc.developer And if you come across any C# code that you need help interpreting, then you might want to look up a C# to VB.Net converter to find some useful tools out on the web. -- Tim Wilson ..Net Compact Framework MVP " A_PK" <pk999(a)hotmail.com> wrote in message news:OlAU2YUGFHA.3648(a)TK2MSFTNGP09.phx.gbl... > How can I read the device ID ? > > my application wanna show the pocket pc device ID. > how to write a code to read the device id ? > >
From: Milsnips on 23 Feb 2005 05:05 Imports System Imports System.Drawing Imports System.Collections Imports System.ComponentModel Imports System.Diagnostics Imports System.Windows.Forms Imports System.Runtime.InteropServices Imports System.Text Public Class DeviceID Inherits System.Windows.Forms.Form Declare Function KernelIoControl Lib "CoreDll.dll" (ByVal dwIoControlCode As Int32, ByVal lpInBuf As IntPtr, ByVal nInBufSize As Int32, ByVal lpOutBuf() As Byte, ByVal nOutBufSize As Int32, ByRef lpBytesReturned As Int32) As Boolean Public Sub New() ' ' Required for Windows Form Designer support ' InitializeComponent() End Sub ' ' TODO: Add any constructor code after InitializeComponent call ' Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) MyBase.Dispose(disposing) End Sub #Region "Windows Form Designer generated code" Private Sub InitializeComponent() ' ' DeviceID ' Me.Text = "DeviceID" End Sub 'InitializeComponent Shared Sub Main() Application.Run(New DeviceID) End Sub 'Main #End Region Private Shared METHOD_BUFFERED As Int32 = 0 Private Shared FILE_ANY_ACCESS As Int32 = 0 Private Shared FILE_DEVICE_HAL As Int32 = &H101 Private Const ERROR_NOT_SUPPORTED As Int32 = &H32 Private Const ERROR_INSUFFICIENT_BUFFER As Int32 = &H7A Private Shared IOCTL_HAL_GET_DEVICEID As Int32 = (&H10000 * FILE_DEVICE_HAL) Or (&H4000 * FILE_ANY_ACCESS) Or (&H4 * 21) Or METHOD_BUFFERED Private Shared Function GetDeviceID() As String ' Initialize the output buffer to the size of a Win32 DEVICE_ID structure ' Dim outbuff(19) As Byte Dim dwOutBytes As Int32 Dim done As Boolean = False Dim nBuffSize As Int32 = outbuff.Length ' Set DEVICEID.dwSize to size of buffer. Some platforms look at ' this field rather than the nOutBufSize param of KernelIoControl ' when determining if the buffer is large enough. ' BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0) dwOutBytes = 0 ' Loop until the device ID is retrieved or an error occurs ' While Not done If KernelIoControl(IOCTL_HAL_GET_DEVICEID, IntPtr.Zero, 0, outbuff, nBuffSize, dwOutBytes) Then done = True Else Dim [error] As Integer = Marshal.GetLastWin32Error() Select Case [error] Case ERROR_NOT_SUPPORTED Throw New NotSupportedException("IOCTL_HAL_GET_DEVICEID is not supported on this device", New Win32Exception([error])) Case ERROR_INSUFFICIENT_BUFFER ' The buffer is not big enough for the data. The required size ' is in the first 4 bytes of the output buffer (DEVICE_ID.dwSize). nBuffSize = BitConverter.ToInt32(outbuff, 0) outbuff = New Byte(nBuffSize) {} ' Set DEVICEID.dwSize to size of buffer. Some ' platforms look at this field rather than the ' nOutBufSize param of KernelIoControl when ' determining if the buffer is large enough. ' BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0) Case Else Throw New Win32Exception([error], "Unexpected error") End Select End If End While Dim dwPresetIDOffset As Int32 = BitConverter.ToInt32(outbuff, &H4) ' DEVICE_ID.dwPresetIDOffset Dim dwPresetIDSize As Int32 = BitConverter.ToInt32(outbuff, &H8) ' DEVICE_ID.dwPresetIDSize Dim dwPlatformIDOffset As Int32 = BitConverter.ToInt32(outbuff, &HC) ' DEVICE_ID.dwPlatformIDOffset Dim dwPlatformIDSize As Int32 = BitConverter.ToInt32(outbuff, &H10) ' DEVICE_ID.dwPlatformIDBytes Dim sb As New StringBuilder Dim i As Integer For i = dwPresetIDOffset To (dwPresetIDOffset + dwPresetIDSize) - 1 sb.Append(String.Format("{0:X2}", outbuff(i))) Next i sb.Append("-") For i = dwPlatformIDOffset To (dwPlatformIDOffset + dwPlatformIDSize) - 1 sb.Append(String.Format("{0:X2}", outbuff(i))) Next i Return sb.ToString() End Function Private Sub DeviceID_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim strDeviceID As String = GetDeviceID() MessageBox.Show(("The ID for this device is " + strDeviceID)) Catch ex As Exception MessageBox.Show(ex.Message.ToString()) End Try End Sub End Class
From: Gernot Frisch on 23 Feb 2005 06:04 " A_PK" <pk999(a)hotmail.com> schrieb im Newsbeitrag news:OlAU2YUGFHA.3648(a)TK2MSFTNGP09.phx.gbl... > How can I read the device ID ? > > my application wanna show the pocket pc device ID. > how to write a code to read the device id ? > > stringclass GetDeviceID() { #define IOCTL_HAL_GET_DEVICEID 0x01010054 unsigned char buffer[512]; DWORD bytesReturned=0; HINSTANCE hi = LoadLibrary(TEXT("coredll.dll")); if(hi) { typedef BOOL (*KernelIoControlptr)(DWORD, LPVOID, DWORD, LPVOID, DWORD, LPDWORD); KernelIoControlptr KernelIoControl = (KernelIoControlptr) GetProcAddress(hi, TEXT("KernelIoControl")); if(KernelIoControl) { if(!KernelIoControl(IOCTL_HAL_GET_DEVICEID, NULL, 0, (void*)buffer, 512, &bytesReturned)) { // Some older PPC devices only return the ID if the buffer == 16 bytes long if(!KernelIoControl(IOCTL_HAL_GET_DEVICEID, 0, 0, (void*)buffer, 16, &bytesReturned)) return DGStr("FA17ED"); } // Now buffer has the bytes for the deviceid, and is bytesReturned bytes long return __Bytes2Hex(buffer, bytesReturned); } } -- -Gernot int main(int argc, char** argv) {printf ("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);} ________________________________________ Looking for a good game? Do it yourself! GLBasic - you can do www.GLBasic.com
From: "Arvind" <arvind on 28 Feb 2005 23:30
i have a functiion to retrieve the device id. in case u dint find a solution yet..can mail me for the code -- ---------------------------------------------------------------------------- ------------------------------------ "eRiva Systems" - Where Technology Meets Life, Every Minute. e-Mail : arvindr(a)erivasystems.com Web Site: www.erivasystems.com Yahoo Messenger : arvish27 " A_PK" <pk999(a)hotmail.com> wrote in message news:OlAU2YUGFHA.3648(a)TK2MSFTNGP09.phx.gbl... > How can I read the device ID ? > > my application wanna show the pocket pc device ID. > how to write a code to read the device id ? > > |