how to get owner Information Name

G

Guest

hi
how to get owner information Name from pocket Pc windows mobile 2005/2003
VS 2003 in .net CF1 vb.net Code

thankxs
 
P

Paul G. Tobey [eMVP]

I believe that the owner name is in the registry at
HKEY_CURRENT_USER\ControlPanel\Owner...

Paul T.
 
S

Simon Hart

Rather than re-inventing the wheel you could use the EnvironmentEx.UserName
property of the OpenNETCF.
 
G

Guest

i could not find any help of that info.

thanks

Simon Hart said:
Rather than re-inventing the wheel you could use the EnvironmentEx.UserName
property of the OpenNETCF.
 
B

Brooke

I don't have the VB code, but here is some C# code that I use all of the
time.

public class OwnerName {

[DllImport("coredll.dll", EntryPoint = "RegOpenKeyEx", SetLastError =
true)] private static extern int RegOpenKeyEx(uint hKey, string lpSubKey,
int ulOptions, int samDesired, ref uint phkResult);
[DllImport("coredll.dll", EntryPoint = "RegQueryValueEx", SetLastError =
true)] private static extern int RegQueryValueEx(uint hKey, string
lpValueName, int lpReserved, ref uint lpType, byte[] lpData, ref int
lpcbData);
[DllImport("coredll.dll", EntryPoint = "RegCloseKey", SetLastError =
true)] private static extern int RegCloseKey(uint hKey);

private const int ERROR_SUCCESS = 0x0;
private const uint HKEY_CURRENT_USER = 0x80000001;

public static string GetOwnerName() {
int lngSize = 256;
uint hlngSubKey = 0;
uint lngType = 0;
long lngResult;
byte[] regData = new byte[256];

//Handle (hlngSubKey) to the "\ControlPanel\Owner" key
lngResult = RegOpenKeyEx(HKEY_CURRENT_USER, @"\ControlPanel\Owner",
0, 0, ref hlngSubKey);

//Read the "Owner" info frm open registry key
lngResult = RegQueryValueEx(hlngSubKey, "Owner", 0, ref lngType,
regData, ref lngSize);

//Release the key handle
lngResult = RegCloseKey(hlngSubKey);

//Return the data
string ownerName = System.Text.Encoding.Unicode.GetString(regData,
0, 72).TrimEnd('\x0');
return ownerName;
}
}
 
G

Guest

where to download the api
thanks


Brooke said:
I don't have the VB code, but here is some C# code that I use all of the
time.

public class OwnerName {

[DllImport("coredll.dll", EntryPoint = "RegOpenKeyEx", SetLastError =
true)] private static extern int RegOpenKeyEx(uint hKey, string lpSubKey,
int ulOptions, int samDesired, ref uint phkResult);
[DllImport("coredll.dll", EntryPoint = "RegQueryValueEx", SetLastError =
true)] private static extern int RegQueryValueEx(uint hKey, string
lpValueName, int lpReserved, ref uint lpType, byte[] lpData, ref int
lpcbData);
[DllImport("coredll.dll", EntryPoint = "RegCloseKey", SetLastError =
true)] private static extern int RegCloseKey(uint hKey);

private const int ERROR_SUCCESS = 0x0;
private const uint HKEY_CURRENT_USER = 0x80000001;

public static string GetOwnerName() {
int lngSize = 256;
uint hlngSubKey = 0;
uint lngType = 0;
long lngResult;
byte[] regData = new byte[256];

//Handle (hlngSubKey) to the "\ControlPanel\Owner" key
lngResult = RegOpenKeyEx(HKEY_CURRENT_USER, @"\ControlPanel\Owner",
0, 0, ref hlngSubKey);

//Read the "Owner" info frm open registry key
lngResult = RegQueryValueEx(hlngSubKey, "Owner", 0, ref lngType,
regData, ref lngSize);

//Release the key handle
lngResult = RegCloseKey(hlngSubKey);

//Return the data
string ownerName = System.Text.Encoding.Unicode.GetString(regData,
0, 72).TrimEnd('\x0');
return ownerName;
}
}

rt said:
i could not find any help of that info.

thanks
 
P

Paul G. Tobey [eMVP]

"Download the API"? What do you mean by that? You've been given all the
code you need.

Paul T.

rt said:
where to download the api
thanks


Brooke said:
I don't have the VB code, but here is some C# code that I use all of the
time.

public class OwnerName {

[DllImport("coredll.dll", EntryPoint = "RegOpenKeyEx", SetLastError =
true)] private static extern int RegOpenKeyEx(uint hKey, string lpSubKey,
int ulOptions, int samDesired, ref uint phkResult);
[DllImport("coredll.dll", EntryPoint = "RegQueryValueEx",
SetLastError =
true)] private static extern int RegQueryValueEx(uint hKey, string
lpValueName, int lpReserved, ref uint lpType, byte[] lpData, ref int
lpcbData);
[DllImport("coredll.dll", EntryPoint = "RegCloseKey", SetLastError =
true)] private static extern int RegCloseKey(uint hKey);

private const int ERROR_SUCCESS = 0x0;
private const uint HKEY_CURRENT_USER = 0x80000001;

public static string GetOwnerName() {
int lngSize = 256;
uint hlngSubKey = 0;
uint lngType = 0;
long lngResult;
byte[] regData = new byte[256];

//Handle (hlngSubKey) to the "\ControlPanel\Owner" key
lngResult = RegOpenKeyEx(HKEY_CURRENT_USER,
@"\ControlPanel\Owner",
0, 0, ref hlngSubKey);

//Read the "Owner" info frm open registry key
lngResult = RegQueryValueEx(hlngSubKey, "Owner", 0, ref lngType,
regData, ref lngSize);

//Release the key handle
lngResult = RegCloseKey(hlngSubKey);

//Return the data
string ownerName =
System.Text.Encoding.Unicode.GetString(regData,
0, 72).TrimEnd('\x0');
return ownerName;
}
}

rt said:
i could not find any help of that info.

thanks

:

Rather than re-inventing the wheel you could use the
EnvironmentEx.UserName
property of the OpenNETCF.

hi
how to get owner information Name from pocket Pc windows mobile
2005/2003
VS 2003 in .net CF1 vb.net Code

thankxs
 

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