-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommon.cpp
More file actions
41 lines (36 loc) · 997 Bytes
/
Common.cpp
File metadata and controls
41 lines (36 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "Common.h"
#include "Msg.h"
#include <shlwapi.h>
Text<TCHAR> getExeFullName()
{
TCHAR exeFullNameBuf[MAX_PATH];
if(!GetModuleFileName(NULL, exeFullNameBuf, sizeof(exeFullNameBuf))) {
Msg(FILELINE) << "GetModuleFileName failed, error " << GetLastError();
return {};
}
return exeFullNameBuf;
}
Text<TCHAR> getExePath()
{
Text<TCHAR> exeFullName = getExeFullName();
if(!exeFullName.length())
return {};
TCHAR exePathBuf[MAX_PATH];
memcpy(exePathBuf, exeFullName, exeFullName.size());
if(PathRemoveFileSpec(exePathBuf))
return Text<TCHAR>(exePathBuf) + '\\';
return exePathBuf;
}
Text<TCHAR> getTempPath()
{
TCHAR tempPath[MAX_PATH];
if(!GetTempPath(MAX_PATH, tempPath)) {
Msg(FILELINE) << "GetTempPath failed, error " << GetLastError();
return {};
}
return tempPath;
}
Text<TCHAR> getLogFullName()
{
return getTempPath() + "wdvc.log";
}