变更一下代码文目录名,防止qt编译中文路径出错。
This commit is contained in:
25
code/cpp/car_dealer_util/source/system/system_util.cpp
Normal file
25
code/cpp/car_dealer_util/source/system/system_util.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#include "system_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const unsigned int BUFFER_SIZE = 1024;
|
||||
|
||||
std::wstring getUserName()
|
||||
{
|
||||
wstring userName;
|
||||
wchar_t szUserName[BUFFER_SIZE];
|
||||
DWORD userNameBufferSize = BUFFER_SIZE;
|
||||
|
||||
if ( GetUserNameW( szUserName, &userNameBufferSize ) == false )
|
||||
{
|
||||
throw runtime_error("获取操作系统用户名失败!");
|
||||
}
|
||||
|
||||
if ( userNameBufferSize != 0 )
|
||||
{
|
||||
userName = szUserName;
|
||||
}
|
||||
|
||||
return userName;
|
||||
}
|
8
code/cpp/car_dealer_util/source/system/system_util.h
Normal file
8
code/cpp/car_dealer_util/source/system/system_util.h
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
std::wstring getUserName();
|
Reference in New Issue
Block a user