OSDN Git Service

Fix a bug where two or more users can't use xkeymacs at the same time on the same...
[xkeymacs/xkeymacs.git] / xkeymacsdll / PipeName.cpp
1 #include "PipeName.h"\r
2 \r
3 void PipeName::Init(LPCTSTR name)\r
4 {\r
5         m_PipeName = tstring(_T("\\\\.\\pipe\\")) + name;\r
6         TCHAR uname[UNLEN + 1] = {_T('\0')};\r
7         ULONG size = UNLEN + 1;\r
8         if (GetUserName(uname, &size)) {\r
9                 tstring str(uname);\r
10                 for (auto iter = str.begin(); iter != str.end(); ++iter)\r
11                         if (*iter == _T('\\'))\r
12                                 *iter = _T('-');\r
13                 m_PipeName = (m_PipeName + _T("-") + str).substr(0, 256);\r
14 \r
15         }\r
16         DWORD error = GetLastError();\r
17 }\r
18 \r
19 LPCTSTR PipeName::GetName()\r
20 {\r
21         return m_PipeName.c_str();\r
22 }