📄 如何得到 windows 的用户名称和产品序列号? (2000.txt
字号:
如何得到 Windows 的用户名称和产品序列号? (2000年8月25日)
本站更新 分类: 作者:srw 推荐: 阅读次数:671
(http://www.codesky.net)
--------------------------------------------------------------------------------
1. 可以用 WNetGetUser() 这个函数来得到 user name;
2. Windows 95 的产品序号可以用 TRegistry 到 Registry Database 中找出来;
// 取得用户名称
function GetUserName: AnsiString;
var
lpName: PAnsiChar;
lpUserName: PAnsiChar;
lpnLength: DWORD;
begin
Result := '';
lpnLength := 0;
WNetGetUser(nil, nil, lpnLength); // 取得字串所需的长度
if lpnLength > 0 then
begin
GetMem(lpUserName, lpnLength);
if WNetGetUser(lpName, lpUserName, lpnLength) = NO_ERROR then
Result := lpUserName;
FreeMem(lpUserName, lpnLength);
end;
end; { GetUserName }
// 取得 Windows 产品序号
function GetWindowsProductID: string;
var
reg: TRegistry;
begin
Result := '';
reg := TRegistry.Create;
with reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey('Software\Microsoft\Windows\CurrentVersion', False);
Result := ReadString('ProductID');
end;
reg.Free;
end;
--------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -