Windows API 之一:GetUserName和GetComputerName
来源:互联网 发布:小学生编程比赛 编辑:程序博客网 时间:2024/06/07 12:30
GetUserName函数,MSDN的解释为:Retrieves the name of the user associated with the current thread,得到运行当前线程的用户名
函数原型:
BOOL WINAPI GetUserName( _Out_ LPTSTR lpBuffer, _Inout_ LPDWORD lpnSize);
实例如下,在VS2008上编译通过
LPTSTR getUserName(){const int MAX_BUFFER_LEN = UNLEN + 1; TCHAR szBuffer[MAX_BUFFER_LEN]; DWORD dwNameLen; LPTSTR userName;dwNameLen = MAX_BUFFER_LEN; if(GetUserName(szBuffer, &dwNameLen)) userName = szBuffer;return userName;}
GetComputerName函数,获取计算机名,MSDN的解释为:retrieves only the NetBIOS name of the local compute
函数原型
BOOL WINAPI GetComputerName( _Out_ LPTSTR lpBuffer, _Inout_ LPDWORD lpnSize);
实例如下,在VS2008上编译通过
CString Authority::getComputerName() {TCHAR infoBuf[MAX_COMPUTERNAME_LENGTH + 1];DWORD bufCharCount = MAX_COMPUTERNAME_LENGTH + 1;// Get and display the name of the computer. CString computerName;if(GetComputerName(infoBuf, &bufCharCount))computerName = CString(infoBuf);return computerName;}
0 0
- Windows API 之一:GetUserName和GetComputerName
- VC++ 得到计算机名和用户名 GetComputerName GetUserName
- VC++ 得到计算机名和用户名 GetComputerName GetUserName
- VC++ 得到计算机名和用户名 GetComputerName GetUserName
- Windows API:GetUserName的用法
- WindowsAPI使用详解——GetComputerName|GetUserName 获取电脑名称和当前用户名
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- Windows API一日一练(71)GetComputerName函数
- 根据metalink脚本学习undo(五)
- HDU 1075 What Are You Talking About (map解法+Trie解法)
- Redis 集群功能说明
- Linux环境下ping命令出现“Destination host unreachable”解决方法
- Android中Service和Thread的区别
- Windows API 之一:GetUserName和GetComputerName
- HDU 5023 线段树+状压
- ios7 获取TextView中图片信息。
- linux下安装shadowsocks
- iOS开发 iOS8 适配
- 关于java'反射机制,获得类的所有方法与字段
- linux cd 命令
- Windows下安装Redis和MongoDB
- FTP命令详解