Mercurial > hg > easyhg
comparison common.cpp @ 76:d575a8f76a53
* Win32 build fixes
author | Chris Cannam |
---|---|
date | Sat, 20 Nov 2010 10:11:00 +0000 |
parents | 10eb97683aa9 |
children | b522aaa2c053 |
comparison
equal
deleted
inserted
replaced
75:295e3ee4a257 | 76:d575a8f76a53 |
---|---|
21 #include <QFileInfo> | 21 #include <QFileInfo> |
22 #include <QProcessEnvironment> | 22 #include <QProcessEnvironment> |
23 #include <QStringList> | 23 #include <QStringList> |
24 | 24 |
25 #include <sys/types.h> | 25 #include <sys/types.h> |
26 | |
27 #ifdef Q_OS_WIN32 | |
28 #define _WIN32_WINNT 0x0500 | |
29 #include <windows.h> | |
30 #include <security.h> | |
31 #else | |
26 #include <pwd.h> | 32 #include <pwd.h> |
33 #endif | |
27 | 34 |
28 QString findExecutable(QString name) | 35 QString findExecutable(QString name) |
29 { | 36 { |
30 if (name != "") { | 37 if (name != "") { |
31 if (name[0] != '/') { | 38 if (name[0] != '/') { |
88 } | 95 } |
89 | 96 |
90 #ifdef Q_OS_WIN32 | 97 #ifdef Q_OS_WIN32 |
91 QString getUserRealName() | 98 QString getUserRealName() |
92 { | 99 { |
93 const int maxlen = 1023; | 100 TCHAR buf[1024]; |
94 TCHAR buf[maxlen + 2]; | 101 long unsigned int maxlen = 1000; |
95 LPTSTR info = buf; | 102 LPTSTR info = buf; |
96 | 103 |
97 if (!GetUserNameEx(NameDisplay, info, maxlen)) { | 104 if (!GetUserNameEx(NameDisplay, info, &maxlen)) { |
105 DEBUG << "GetUserNameEx failed: " << GetLastError() << endl; | |
98 return ""; | 106 return ""; |
99 } | 107 } |
100 | 108 |
101 return QString::fromUcs2(info); | 109 #ifdef UNICODE |
110 return QString::fromUtf16((const unsigned short *)info); | |
111 #else | |
112 return QString::fromLocal8Bit(info); | |
113 #endif | |
102 } | 114 } |
103 #else | 115 #else |
104 #ifdef Q_OS_MAC | 116 #ifdef Q_OS_MAC |
105 // Nothing here: definition is in common_osx.mm | 117 // Nothing here: definition is in common_osx.mm |
106 #else | 118 #else |