怎么取得WINDOWS当前登录名?

zhutaozhi53 2003-03-21 12:47:17
怎么取得WINDOWS当前登录名?
最好有例程!
...全文
44 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yeahchang 2003-03-22
  • 打赏
  • 举报
回复
beerxuxu其实用的是WMI,不过要保证你有WMI才行!
zhutaozhi53 2003-03-21
  • 打赏
  • 举报
回复
谢谢了,我已经做好了,以前是我定义的类型不对而已!
halibut 2003-03-21
  • 打赏
  • 举报
回复
char buf[256];
memset(buf,0,256);
GetUserName(buf,256);
halibut 2003-03-21
  • 打赏
  • 举报
回复
GetUserName() API
beerxuxu 2003-03-21
  • 打赏
  • 举报
回复
::GetCurrentUser();
以下有段VB代码,很好懂的。

The following example shows you how to call this method to get the current user.

Dim Identification As SWbemObject
Dim UserName As String

Set Identification = GetObject("winmgmts:\root\sms\site_<sitecode>:SMS_Identification")
Identification.GetCurrentUser UserName

MsgBox "UserName = " & UserName

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧