473,320 Members | 1,950 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,320 software developers and data experts.

WNetGetUser

I would liike to know which C# function is the replacement for the following
function, and how do I use Platform SDK functions which r not updated in .Net
Framework.

CHAR nUser[100];
DWORD mError = 80,test ;
test = WNetGetUser(NULL, nUser, &mError);

if(test == NO_ERROR){
// Show Current Log On User
AfxMessageBox(nUser,MB_OK);
}
Nov 17 '05 #1
3 3706

AbdSol wrote:
I would liike to know which C# function is the replacement for the following function, and how do I use Platform SDK functions which r not updated in .Net Framework.

CHAR nUser[100];
DWORD mError = 80,test ;
test = WNetGetUser(NULL, nUser, &mError);

if(test == NO_ERROR){
// Show Current Log On User
AfxMessageBox(nUser,MB_OK);
}


How about this:

System.Security.Principal.WindowsIdentity wid
= System.Security.Principal.WindowsIdentity.GetCurre nt();

string user = wid.Name;

System.Windows.Forms.MesssageBox.Show( user );

Nov 17 '05 #2
It works but not as I want. the output is includes the computer name
"computername\user"

"Mohammad" wrote:

AbdSol wrote:
I would liike to know which C# function is the replacement for the

following
function, and how do I use Platform SDK functions which r not updated

in .Net
Framework.

CHAR nUser[100];
DWORD mError = 80,test ;
test = WNetGetUser(NULL, nUser, &mError);

if(test == NO_ERROR){
// Show Current Log On User
AfxMessageBox(nUser,MB_OK);
}


How about this:

System.Security.Principal.WindowsIdentity wid
= System.Security.Principal.WindowsIdentity.GetCurre nt();

string user = wid.Name;

System.Windows.Forms.MesssageBox.Show( user );

Nov 17 '05 #3

AbdSol wrote:
It works but not as I want. the output is includes the computer name "computername\user"


Then how about:

System.Security.Principal.WindowsIdentity wid
= System.Security.Principal.WindowsIdentity.GetCurre nt();

string[] domainAndUser = wid.Name.Split( '\\' );
user = domainAndUser[1];

System.Windows.Forms.MesssageBox.Show( user );

I mean... RT(*BEEB*)M for goodness sake.

Nov 17 '05 #4

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

Similar topics

9
by: diverdon99 | last post by:
I have a database that is using an audit table that logs the machine and user to each record change. My problem is that more than 1 user uses the same login, (this will not change!) hence the audit...
15
by: simonmarkjones | last post by:
I want to validate my form using a BeforeUpdate event. However now that i call my code with a beforeupdate it wont let me go to next or previous records. What code should i put in o allow me...
2
by: Homauoon | last post by:
Dear sir I want to get current user name from system (in windows applications) by using WNetGetUser function from Mpr.lib. Please help me. Thanks
5
by: Phil Barber | last post by:
I have a Windows App, Using the Win32's I used "WNetGetUser" (winsock API ) to get the NT login name. what is the best way to achive this in C#? thanks Phil.
1
by: NevH2001 | last post by:
Hi all, I'm trying to get the network user by calling the WNetGetUser in vb.net, what is the syntax? thanks Nev
4
samycbe
by: samycbe | last post by:
Hi, How to get the windows login name from vb? samy
3
by: trixxnixon | last post by:
so im using the function below in a module. This works, when i press the run button the msg box pops up with my correct user name. how could i get a field in a form to populate with the output...
8
by: Raven7738 | last post by:
Hey, So I originally had a form asking for an ID and password. A query would take those two values and pull up information in a database that contained both those values. I need to change this so...
5
by: JonHuff | last post by:
Here is my code. I am trying to INSERT INTO "Master_Table" field "Edited_By" the variable value of "Editor" "Editor" is the User Name of the person logged onto that computer Code Option...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.