Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than netapi32, prefix the name with the module name and a period.
NetWkstaUserGetInfo (netapi32)
.
C# Signature:
[DllImport("netapi32.dll", SetLastError=true)]
static extern TODO NetWkstaUserGetInfo(
[MarshalAs(UnmanagedType.LPWStr)]string reserved,
int level, out IntPtr lpBuffer);
VB Signature:
Declare Function NetWkstaUserGetInfo Lib "netapi32.dll" (ByVal reserved As String, ByVal level As Integer, ByRef lpBuffer As IntPtr) As Integer
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string wkui1101_username;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string wkui1101_logon_domain;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string wkui1101_logon_server;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string wkui1101_oth_domains;
}
Alternative Managed API:
Do you know one? Please contribute it!
Notes:
None.
Tips & Tricks:
Please add some!
Sample Code:
Private Sub GetLoggedInUserInfo()
Dim lpBuffer As IntPtr
Dim result As Integer = NetWkstaUserGetInfo(Nothing, 1, lpBuffer)
If result = 0 Then
Dim wksInfo As WKSTA_USER_INFO_1 = Marshal.PtrToStructure(lpBuffer, GetType(WKSTA_USER_INFO_1))
''' Do something
NetApiBufferFree(lpBuffer)
End If
End Sub
C# Sample
/// <summary>
/// Retrieves the default domain for the currently logged in user.
/// </summary>
/// <returns>The name of the domain currently logged into.</returns>
public static string GetDefaultDomain()
{
IntPtr buffer = new IntPtr();
string domain = "";
int result;
WKSTA_USER_INFO_1101 wksInfo;
result = NetWkstaUserGetInfo(null, 1, out buffer);
if (result == 0)
{
Int32 pointer = buffer.ToInt32();
wksInfo = (WKSTA_USER_INFO_1101)Marshal.PtrToStructure(
new IntPtr(pointer), typeof(WKSTA_USER_INFO_1101));
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).