Develop and Download Open Source Software

Browse Subversion Repository

Contents of /common/GetAccountName.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 275 - (show annotations) (download) (as text)
Sun Mar 9 08:47:25 2008 UTC (16 years, 2 months ago) by satofumi
File MIME type: text/x-c++src
File size: 543 byte(s)
rename GetAccountName.cpp
1 /*!
2 \file
3 \brief ƒ†[ƒU–ź‚̎擞
4
5 \author Satofumi KAMIMURA
6
7 $Id$
8 */
9
10 #include "GetAccountName.h"
11 #include "DetectOS.h"
12 #ifdef WINDOWS_OS
13 #include <windows.h>
14 #endif
15 #include <stdlib.h>
16
17
18 std::string beego::GetAccountName(void) {
19
20 #ifdef WINDOWS_OS
21 enum { NameMax = 32 };
22 DWORD length = NameMax;
23 char buffer[NameMax];
24 if (GetUserNameA(buffer, &length)) {
25 return std::string(buffer);
26 } else {
27 return "";
28 }
29 #else
30 // Linux —pŽŔ‘•
31 const char* p = getenv("USER");
32 return std::string((p == NULL) ? "" : p);
33 #endif
34 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26