增加获取当前登录用户名功能,增加送返修工单excel文件读取功能。
This commit is contained in:
25
代码/cpp/car_dealer_util/source/system/system_util.cpp
Normal file
25
代码/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
代码/cpp/car_dealer_util/source/system/system_util.h
Normal file
8
代码/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