Simply obtaining the Mobile Phone Number of the User

S

sauly

Hello all,

I have written an application used by a large number of remote sales
staff. When they sync their daily data, I want to know what phone
number (SIM) they have in their smartphone. I have already used the
TAPI to find the IMEI of the device.

There seems to be quite a lot of information about how to find the
phone number of the caller when a call comes in, but I'm just trying
to find the phone number of the device itself. In other words, what
you see in Start Menu : Settings : Personal (tab) : Phone : "Phone
Number". Or, to put it a third way, if it was my mobile phone, what my
own mobile phone number was.

The application is written for an XDA II device, PocketPC version 4.2.
In Visual Basic, compact framework.

Any help appreciated! Thanks a lot in advance, as this is driving me
nuts.

Regards,
Saul
 
B

Bjorn Brox

sauly skrev:
Hello all,

I have written an application used by a large number of remote sales
staff. When they sync their daily data, I want to know what phone
number (SIM) they have in their smartphone. I have already used the
TAPI to find the IMEI of the device.

There seems to be quite a lot of information about how to find the
phone number of the caller when a call comes in, but I'm just trying
to find the phone number of the device itself. In other words, what
you see in Start Menu : Settings : Personal (tab) : Phone : "Phone
Number". Or, to put it a third way, if it was my mobile phone, what my
own mobile phone number was.

The application is written for an XDA II device, PocketPC version 4.2.
In Visual Basic, compact framework.

Any help appreciated! Thanks a lot in advance, as this is driving me
nuts.
To get the telephone number as written in your "setting, personal,
Phone" is easy, but you don't have any guarantee that it is the real
phone number since thus user can type anything in that field.

Your only real ID you can trust for the phone is the IMEI.


C#
String phone_number = SystemState.OwnerPhoneNumber.

or
String phone_number =
SystemState.GetValue(SystemProperty.OwnerPhoneNumber).ToString();
 
S

saulysw

Bjorn,

Thank you very much for your reply.

Sadly, it doesn't work for me as I am using Windows Mobile 2003, and
the SystemState class is only in Windows Mobile 6. It is exactly what
I am looking for though - something as simple as this....

Regards,
Saul
 
C

Christian Resma Helle

There was an old article on PocketPCDN on how to do this in native code:
http://www.pocketpcdn.com/articles/ownerinformation.html

Here's the managed version of it:

-----------------------------------------------------------------------------------
string owner_phone;

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"\ControlPanel\Owner");
if (key != null) {
byte[] value = key.GetValue("Owner", null) as byte[];
if (value != null) {
owner_phone = Encoding.Unicode.GetString(value, 0x204, 50);
int index = owner_phone.IndexOf('\0');
if (index != -1) {
owner_phone = owner_phone.Substring(0, index);
}
}
key.Close();
}

MessageBox.Show(owner_phone, "Owner Phone");
 
S

saulysw

Christian,

Thank you for your suggestion. You are both ledgends in my books for
doing this!

Unfortunately, your solution is also not really that good for me,
although I can use your code. The issue is that the Owner section is
user-configurable, and I know they have not put that info in the
"Phone number" field, and even if they have, I can't trust it. People
swap SIM cards on me. What I really want is to be able to query the
SIM card and find out what phone number it really has. The machine
*does* know what it's own number is, without user input, as it's in
the Start Menu : Settings : Personal (tab) : Phone : "Phone Number"
field. This is not the same as the Owner information area, and it is
not changable by the user (ie its a label field, not input textbox).

I really appreciate the time/effort you guys have given for this, but
I am still looking for a solution.

Regards,
Saul
 
G

Guest

If you want the actual number, it's available through TAPI. TAPI, however,
is far from fun or easy to use in native code and it's much worse in managed
code. OpenNETCF has a Telephony library that wraps TAPI for managed code,
but it's not free. There are some reasonable online resources and
documentation for TAPI and if you've got time and a bit of P/Invoke skill,
it can be resolved.
 
S

saulysw

Chris,

I know you could do it, I have a deep respect for your abilities, and
you've helped me before.

Am i right in thinking that I can't get the number from TAPI unless I
actually am in an active call? I really am having trouble finding
resources on the TAPI library, do you know where I can go for more
info? You tease me slightly by saying they are around, but not telling
me where! I'm already using the Tapilib.dll version 1.0.1600 to get
the IMEI. I would endure some more pain to get the phone number, I
just can't work out how.

I know the Telephone library from OpenNETCF is there, and for my users
it would be $500 to buy. It seems to me that some of the documentation
for the older TAPI seems to have dissapeared -- perhaps to encourage
people to buy this? Or am I being cynical?

Thanks again,
Saul
 
P

Peter Foot

The relevant TAPI method is lineGetAddressCaps - I can't remember if this is
exposed in TapiLib it's been a long time since I used that library. This
will only retrieve the phone number if it is stored on your SIM card. This
is how the Settings > Personal > Phone gets the number for display. On some
devices no address is stored.

Peter
 
G

Guest

Am i right in thinking that I can't get the number from TAPI unless I
actually am in an active call?

Just an open handle, not an active call.
I really am having trouble finding
resources on the TAPI library, do you know where I can go for more
info? You tease me slightly by saying they are around, but not telling
me where! I'm already using the Tapilib.dll version 1.0.1600 to get
the IMEI. I would endure some more pain to get the phone number, I
just can't work out how.

I was on the couch watching TV when I posted last night, so my desire to do
searching for you wasn't high at that point. These are probably relevent:

http://msdn2.microsoft.com/en-us/library/ms862517.aspx
http://msdn2.microsoft.com/en-us/library/ms893350.aspx

I know the Telephone library from OpenNETCF is there, and for my users
it would be $500 to buy. It seems to me that some of the documentation
for the older TAPI seems to have dissapeared -- perhaps to encourage
people to buy this? Or am I being cynical?

The "old" library was one that Alex Feinman put together as a sample and he
published through his own web site. It wasn't heavily tested and was
unsupported. We went through, did a bunch of bug fixes and solidified the
object model and turned it into a product and therefore the old library went
away, just as older versions of most do. The last thing we need is an
increased support load from people asking questions about an old library
that we know has problems and that they got for nothing.

We admit that $500 may be steep for the hobbiest, but when amortized of the
life of a commercial product, you don't have to sell too many before it
become a negligible part of a product cost. The cost involved in the number
of hours it would take most people to develop the same functionality is also
a lot higher than $500, so looking at those two points we feel that the
price isn't too heavvy a burden for most. For those that it is still too
much for - well there's always the MSDN docs.
 

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

Top