Ivana Hudakova

I use this function to get user name on Windows XP, and it works:

[DllImport("secur32.dll", CharSet = CharSet.Auto)]

public static extern int GetUserNameEx(int nameFormat, StringBuilder userName, ref uint userNameSize);

When I try to call the same funcion on Windows CE 5.0 it fails...

[DllImport("coredll.dll", CharSet = CharSet.Auto)]

public static extern int GetUserNameEx(int nameFormat, StringBuilder userName, ref uint userNameSize);

GetLastError() function returns "87 The parameter is incorrect ERROR_INVALID_PARAMETER"

I checked out each of EXTENDED_NAME_FORMAT value, with the same result.

Any suggestion

Thx, Ivana



Re: Smart Devices VB and C# Projects GetUserNameEx in coredll

Ivana Hudakova

Sorry, I was wrong.

here is another enumeration

http://msdn2.microsoft.com/en-gb/library/ms724268.aspx

I needed this one:

public enum EXTENDED_NAME_FORMAT : uint

{

NameUnknown = 0,

NameFullyQualifiedDN = 1,

NameSamCompatible = 2,

NameDisplay = 3,

NameUniqueId = 6,

NameCanonical = 7,

NameUserPrincipal = 8,

NameCanonicalEx = 9,

NameServicePrincipal = 10,

NameWindowsCeLocal = 0x80000001

}

Function GetUserNameEx wtih parameter EXTENDED_NAME_FORMAT.NameWindowsCeLocal works, but return "default" string.

So I thing this is not a good way how to get a user name

Ivana





Re: Smart Devices VB and C# Projects GetUserNameEx in coredll

Peter Foot

Since Windows CE is not a multiuser OS it doesn't have the same need for a Username. If your device is Windows Mobile 5.0 you can use Microsoft.WindowsMobile.Status.SystemState.OwnerName to get the owner name entered into the device.

Peter