How do I read PocketPC registry from ASP.NET application

G

Goran Djuranovic

Hi All,
I would like to be able to read Device ID from PocketPC.
I guess I have to read PocketPC's registry somehow.
How do I do this?
 
J

Jean-Luc David [MVP]

Hi Goran,

Previous versions of the MMIT had the UniqueDeviceID method
within the System.Web.Mobile.MobileCapabilities class. Since
Beta 2, Microsoft removed this functionality due to privacy
concerns (& because it didn't work on all devices).

Your best bet is to look at the HTTP headers sent from the PocketPC
device. Something to the effect of:

NameValueCollection reqHeaders;
reqHeaders=Request.Headers;

If you want to know more about HTTP headers, I wrote a detailed
article on Builder.com: http://builder.com.com/5100-6371-1044588.html

I hope this information helps.

Thanks,
Jean-Luc David
Microsoft .NET MVP
(e-mail address removed)
http://www.stormpixel.com
http://www.mobilecoder.net

--------------------------------------------------------------
 
G

Goran Djuranovic

Jean-Luc,
Is there anything unique in the HTTP header that is being sent to the
server?
Something besides: "Connection", "Cookie", "UA-OS", "UA-CPU", etc.
Also, is it possible to hardcode something into the device that will add new
value to the header?
For example, something like "UA-DeviceID".

Thanks
Goran

Jean-Luc David said:
Hi Goran,

Previous versions of the MMIT had the UniqueDeviceID method
within the System.Web.Mobile.MobileCapabilities class. Since
Beta 2, Microsoft removed this functionality due to privacy
concerns (& because it didn't work on all devices).

Your best bet is to look at the HTTP headers sent from the PocketPC
device. Something to the effect of:

NameValueCollection reqHeaders;
reqHeaders=Request.Headers;

If you want to know more about HTTP headers, I wrote a detailed
article on Builder.com: http://builder.com.com/5100-6371-1044588.html

I hope this information helps.

Thanks,
Jean-Luc David
Microsoft .NET MVP
(e-mail address removed)
http://www.stormpixel.com
http://www.mobilecoder.net

--------------------------------------------------------------
 
J

Jean-Luc David [MS-MVP]

Hi Goran,

As far as I can tell, the DeviceID can't be passed into a custom User
Agent unless you have an application that runs on the PocketPC that
modifies the User Agent value in the registry. Keep in mind that this
can't be done using a web browser - the user will be required to install
or run an application on the device. As a general rule, the registry can't
easily be accessed from a web browser for obvious security reasons.

Here is the UserAgent key in the Pocket PC registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\Internet Settings\UserAgent

You also have the option of creating a multimodal web application. In other
words, create a client program (using eVB/eVC++ or .NET CF) that
interacts with Pocket IE. For example, here is an article that I found
that shows how to retrieve the Pocket PC Owner Information using eVB:
http://www.devbuzz.com/content/zinc_evb_retrieve_owner_info_pg1.asp

If you have direct hands-on access to your web server, you can try
installing a pre-Beta 2 version of MMIT. Don't try this option in a
production
environment. There are obvious security and stability concerns when you use
any beta software. However, in a test environment you can check out the
effectiveness of the UniqueDeviceID method to retrieve the Pocket PC
Owner Information.

Good luck. I hope this information is useful to you.

Thanks,
Jean-Luc David
Microsoft .NET MVP
(e-mail address removed)
http://www.stormpixel.com
http://www.mobilecoder.net
 
G

Goran Djuranovic

Hi Jean-Luc,
Thanks for your response. It has been a long time, and I totally forgot to
update this message thread. I actually found the way to uniquely identify
each device accessing the website. Each device has a unique MAC address
(from Wi-Fi card), and below is the code to read that from the server. Note
that PDA's IP address needs to be read first, in order to get the MAC
address. Hope this helps someone:
To pass the IP address use this:

GetMACAddress(Request.ServerVariables("REMOTE_ADDR"))

--------------------------- Code ---------------------------------

Public Function GetMACAddress(ByVal strIP As String) As String
Try
Dim strProcessLine As String
Dim psiMACAddress As ProcessStartInfo = New ProcessStartInfo
Dim proMACAddress As New Process

psiMACAddress.FileName = "nbtstat"
psiMACAddress.RedirectStandardInput = False
psiMACAddress.RedirectStandardOutput = True
psiMACAddress.Arguments = "-A " & strIP
psiMACAddress.UseShellExecute = False
proMACAddress = Process.Start(psiMACAddress)

intCount = 0
intMACCount = -1
Do Until intMACCount > -1
If strProcessLine <> Nothing Then
intMACCount = strProcessLine.Trim.ToLower.IndexOf("mac
address", 0)
If intMACCount > -1 Then
Exit Do
End If
End If
If strProcessLine = "Host not found." Or intCount > 50 Then
strProcessLine = "No MAC address found."
Exit Do
End If
strProcessLine = proMACAddress.StandardOutput.ReadLine
strProcessLine = strProcessLine.Trim()
intCount = intCount + 1
Loop
proMACAddress.WaitForExit()
GetMACAddress = SeparateMACAddress(strProcessLine.Trim, "=").Trim
Catch Ex As Exception
tcErrorMessage.Visible = True
tcErrorMessage.Text = "Error has occured. Please notify
administrator!"
'tcErrorMessage.Text = Ex.ToString()
End Try
End Function

Public Function SeparateMACAddress(ByVal strRawMACAddress As String, ByVal
strSeparationCharacter As String) As String
Try
If InStr(1, strRawMACAddress, strSeparationCharacter) <> 0 Then
SeparateMACAddress =
Microsoft.VisualBasic.Right(strRawMACAddress, Len(strRawMACAddress) -
InStr(1, strRawMACAddress, strSeparationCharacter))
Else
SeparateMACAddress = strRawMACAddress
End If
Catch Ex As Exception
tcErrorMessage.Visible = True
tcErrorMessage.Text = "Error has occured. Please notify
administrator!"
'tcErrorMessage.Text = Ex.ToString()
End Try
End Function
------------------------- End Code ---------------------------------

Goran Djuranovic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top