473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Get the Name and Phone Number of the Current Windows User in a .NET Application

Get the Name and Phone Number of the Current Windows User in a .NET
Application

I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.

I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.

My question is how I get this environment information in a C#
application.

I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.

Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.

Your input is highly appreciated.

Thanks.

Alex

Jul 10 '07 #1
9 2983
You might try the microsoft.public.officedev ng[1]. There's more people
hanging out there that are familar with developing with Outlook.

[1]
http://msdn.microsoft.com/newsgroups...&lang=en&cr=US
--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"Alex" wrote:
Get the Name and Phone Number of the Current Windows User in a .NET
Application

I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.

I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.

My question is how I get this environment information in a C#
application.

I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.

Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.

Your input is highly appreciated.

Thanks.

Alex

Jul 10 '07 #2
Alex,

This is going to be near impossible. First, the full name of a user is
not always stored with the user account. You can get that from the Outlook
profile most likely (or any Office app, through interop), but the phone
number is by no means guaranteed.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alex" <bo*******@gmail.comwrote in message
news:11**********************@r34g2000hsd.googlegr oups.com...
Get the Name and Phone Number of the Current Windows User in a .NET
Application

I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.

I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.

My question is how I get this environment information in a C#
application.

I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.

Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.

Your input is highly appreciated.

Thanks.

Alex
Jul 10 '07 #3
You can get the current user name by using Environment.UserName
The logon name may differ from the legal name of the user. For example, many
users log on as "Administrator"...
--
Sheng Jiang
Microsoft MVP in VC++
"Alex" <bo*******@gmail.comwrote in message
news:11**********************@r34g2000hsd.googlegr oups.com...
Get the Name and Phone Number of the Current Windows User in a .NET
Application

I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.

I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.

My question is how I get this environment information in a C#
application.

I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.

Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.

Your input is highly appreciated.

Thanks.

Alex

Jul 10 '07 #4
Thanks, Nick for the input.

The people who uses my application have already had their Windows and
Outlook properly set up.

On Jul 10, 2:16 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Alex,

This is going to be near impossible. First, the full name of a user is
not always stored with the user account. You can get that from the Outlook
profile most likely (or any Office app, through interop), but the phone
number is by no means guaranteed.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Alex" <bohema...@gmail.comwrote in message

news:11**********************@r34g2000hsd.googlegr oups.com...
Get the Name and Phone Number of the Current Windows User in a .NET
Application
I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.
I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.
My question is how I get this environment information in a C#
application.
I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.
Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.
Your input is highly appreciated.
Thanks.
Alex- Hide quoted text -

- Show quoted text -

Jul 10 '07 #5
Sheng,

Thanks for the input. Let's say my logon name is AlexLogOnName, but
when I click the Start Button of my Windows, my name -- LastName, Alex
-- is shown in the popup menu. I guess my Windows is properly set up
with user's logon name and user's real name (Last, first). Any input
on how windows differentiate logon and real name (last, first)?

On Jul 10, 3:03 pm, "Sheng Jiang[MVP]"
<sheng_ji...@hotmail.com.discusswrote:
You can get the current user name by using Environment.UserName
The logon name may differ from the legal name of the user. For example, many
users log on as "Administrator"...
--
Sheng Jiang
Microsoft MVP in VC++"Alex" <bohema...@gmail.comwrote in message

news:11**********************@r34g2000hsd.googlegr oups.com...
Get the Name and Phone Number of the Current Windows User in a .NET
Application
I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.
I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.
My question is how I get this environment information in a C#
application.
I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.
Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.
Your input is highly appreciated.
Thanks.
Alex- Hide quoted text -

- Show quoted text -

Jul 10 '07 #6
Alex,

If that's the case, then you should be able to access the information in
Outlook through the Outlook object model (using the primary interop
assemblies for Outlook).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alex" <bo*******@gmail.comwrote in message
news:11**********************@p39g2000hse.googlegr oups.com...
Thanks, Nick for the input.

The people who uses my application have already had their Windows and
Outlook properly set up.

On Jul 10, 2:16 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
>Alex,

This is going to be near impossible. First, the full name of a user
is
not always stored with the user account. You can get that from the
Outlook
profile most likely (or any Office app, through interop), but the phone
number is by no means guaranteed.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Alex" <bohema...@gmail.comwrote in message

news:11**********************@r34g2000hsd.googleg roups.com...
Get the Name and Phone Number of the Current Windows User in a .NET
Application
I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.
I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.
My question is how I get this environment information in a C#
application.
I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.
Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.
Your input is highly appreciated.
Thanks.
Alex- Hide quoted text -

- Show quoted text -

Jul 10 '07 #7
Thanks. Nick ...

Alex

On Jul 10, 3:17 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Alex,

If that's the case, then you should be able to access the information in
Outlook through the Outlook object model (using the primary interop
assemblies for Outlook).

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Alex" <bohema...@gmail.comwrote in message

news:11**********************@p39g2000hse.googlegr oups.com...
Thanks, Nick for the input.
The people who uses my application have already had their Windows and
Outlook properly set up.
On Jul 10, 2:16 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Alex,
This is going to be near impossible. First, the full name of a user
is
not always stored with the user account. You can get that from the
Outlook
profile most likely (or any Office app, through interop), but the phone
number is by no means guaranteed.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Alex" <bohema...@gmail.comwrote in message
>news:11**********************@r34g2000hsd.googleg roups.com...
Get the Name and Phone Number of the Current Windows User in a .NET
Application
I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.
I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.
My question is how I get this environment information in a C#
application.
I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.
Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.
Your input is highly appreciated.
Thanks.
Alex- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Jul 10 '07 #8
try NetUserGetInfo

http://pinvoke.net/default.aspx/neta...erGetInfo.html
--
Sheng Jiang
Microsoft MVP in VC++
"Alex" <bo*******@gmail.comwrote in message
news:11*********************@n2g2000hse.googlegrou ps.com...
Sheng,

Thanks for the input. Let's say my logon name is AlexLogOnName, but
when I click the Start Button of my Windows, my name -- LastName, Alex
-- is shown in the popup menu. I guess my Windows is properly set up
with user's logon name and user's real name (Last, first). Any input
on how windows differentiate logon and real name (last, first)?

On Jul 10, 3:03 pm, "Sheng Jiang[MVP]"
<sheng_ji...@hotmail.com.discusswrote:
You can get the current user name by using Environment.UserName
The logon name may differ from the legal name of the user. For example,
many
users log on as "Administrator"...
--
Sheng Jiang
Microsoft MVP in VC++"Alex" <bohema...@gmail.comwrote in message

news:11**********************@r34g2000hsd.googlegr oups.com...
Get the Name and Phone Number of the Current Windows User in a .NET
Application
I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.
I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.
My question is how I get this environment information in a C#
application.
I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.
Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.
Your input is highly appreciated.
Thanks.
Alex- Hide quoted text -
- Show quoted text -


Jul 10 '07 #9
First, thank you for all your help

Some update:

1. I can easily get users Windows login name which is the SAME as
Outlook email Alias, by using Environment.UserName

2. After add Outlook Object references, I can do something like:

Outlook._Application olApp = new
Outlook.ApplicationClass();
Outlook.NameSpace oNS = olApp.GetNamespace("MAPI");
Outlook.AddressList oAL = oNS.AddressLists["Global Address
List"];
Outlook.AddressEntries oAEs = oAL.AddressEntries;

In this way, I can get the AddressEntries. My question is can I
search the AddressEntries for the user login name I found by using
Environment.UserName? I did not find a method for search/find

On Jul 10, 1:49 pm, Alex <bohema...@gmail.comwrote:
Get the Name and Phone Number of the Current Windows User in a .NET
Application

I am writing a simple .NET (C#) application. It needs to "automatic"
get the Name (last, first) and phone number of the current Windows
user.

I guess the name can be retrieved from the environment -- After I
click the Start button of Windows, my name is on the very first line
of the popup menu. So, this information is provided by the Windows
environment.

My question is how I get this environment information in a C#
application.

I also need to get the phone number of the current Windows user. I
can safely assume:
(1) Outlook is installed.
(2) The phone number of the current Windows user is in the Outlook
profile.

Is there a way to obtain the phone number of the current Windows
user? We canNOT assume that Outlook is running when my application is
running.

Your input is highly appreciated.

Thanks.

Alex

Jul 11 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Robert Mark Bram | last post by:
Hi All! Is there a way to reference a window by name without doing something like this: open (, 'windowName'); The open method will open a blank window if there is no window with such a name....
3
by: Tomasz \Boruh\ Borowiak | last post by:
Does anybody have any idea how to write a c++ console application which simulates the mobile phone keyboard ? for Example: when i write SMS I hit 2 - I get "a" I hit 22 - I get "b" I hit 222...
3
by: deko | last post by:
I have a (Access 2003) contact management database where the user can double-click a contact's phone number in a form and have the Windows Phone Dialer dial the number. The problem is the number...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
3
by: Ray | last post by:
Dear all, Now, I have 3 projects of class library and 1 project of window application. The window application will call the 3 class librarys. So should I make 4 .snk files for each project? Or one...
4
by: Earl | last post by:
I'm curious if there are others who have a better method of accepting/parsing phone numbers. I've used a couple of different techniques that are functional but I can't really say that I'm totally...
18
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample...
0
by: hennas | last post by:
Basically i want to design a membership Name and Telephone List form using the following command buttons. Edit Add New; Update; Delete; Cancel; Save; Clear, and Exit
10
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Hi everybody, I'm trying to use the new VB 2008 right now and I want to know how to preset the company name and copyright informtion in Assembly Information. In my current VB 2005, company name...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.