一个delphi编程的问题? 要用到windows API 和注册表 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 比喻说,得到Windows的用户名称和产品序列号。1. 可以用 WNetGetUser() 这个函数来得到 user name;2. Windows 的产品序号可以用 TRegistry 到 Registry Database 中找出来;// 取得用户名称function GetUserName: AnsiString;varlpName: PAnsiChar;lpUserName: PAnsiChar;lpnLength: DWORD;beginResult := '';lpnLength := 0;WNetGetUser(nil, nil, lpnLength); // 取得字串长度if lpnLength > 0 thenbeginGetMem(lpUserName, lpnLength);if WNetGetUser(lpName, lpUserName, lpnLength) = NO_ERROR thenResult := lpUserName;FreeMem(lpUserName, lpnLength);end;end; { GetUserName }// 取得 Windows 产品序号........... 如此的调用线程,为何不起作用? 为啥pos函数失效?....网页中的字符串有问题吗 如何将memo控件里的内容提交到数据库 剪切板数据监控问题,急! 请问,如何防止编译后的EXE中的SQL连接密码被UE这样的文本编辑器看到? 窗体关闭 强烈迷惑:IntraWeb 和asp/asp.net,jsp或php相比有什么优势. 各位,你们是如何学好delphi的?高分求救100 2个小问题 在大富翁上没有答案,到此打听一下 delphi 5 动态连接数据库?(现要用) 怎样在PageControl的页标签上添加右键弹出菜单?(不管用什么方法,请说得详细点!)
1. 可以用 WNetGetUser() 这个函数来得到 user name;
2. Windows 的产品序号可以用 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 thenResult := lpUserName;
FreeMem(lpUserName, lpnLength);
end;
end; { GetUserName }// 取得 Windows 产品序号
...........