C++ GetComputerName()

关于函数“GetComputerName()”,参考:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724295(v=vs.85).aspx

关于“Computer Names”,参考:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724220(v=vs.85).aspx

代码摘自“Getting System Information”,参考:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724426(v=vs.85).aspx

关于“Windows Data Types”,参考:https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx

IDE: Code::Blocks

操作系统:Windows 7 x64

 #include <stdio.h>
#include <tchar.h>
#include <windows.h> #define INFO_BUFFER_SIZE (MAX_COMPUTERNAME_LENGTH + 1) int main()
{
CHAR infoBuf[INFO_BUFFER_SIZE];
DWORD bufCharCount = INFO_BUFFER_SIZE; // Get and display the name of the computer.
if( GetComputerName( infoBuf, &bufCharCount ) ) {
_tprintf( "The NetBIOS name of the local computer is %s \n", infoBuf );
}
else {
_tprintf( "Get NetBIOS name of the local computer failed with error %lu \n", GetLastError() );
} return ;
}
上一篇:jquery 获取$("#id").text()里面的值 需要进行去空格去换行符操作


下一篇:27.Spring-Boot中拦截器中静态资源的处理(踩过坑)以及Spring mvc configuring拓展介绍