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
how to get owner information Name from pocket Pc windows mobile 2005/2003
VS 2003 in .net CF1 vb.net Code
thankxs
Simon Hart said:Rather than re-inventing the wheel you could use the EnvironmentEx.UserName
property of the OpenNETCF.
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
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
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.