-
Notifications
You must be signed in to change notification settings - Fork 13
/
PathHelper.cpp
44 lines (35 loc) · 1.05 KB
/
PathHelper.cpp
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
42
43
44
#include "pch.h"
#include "PathHelper.h"
using namespace NppShell::Helpers;
using namespace std::filesystem;
extern HMODULE g_module;
const path GetModulePath()
{
wchar_t pathBuffer[MAX_PATH] = { 0 };
GetModuleFileNameW(g_module, pathBuffer, MAX_PATH);
return path(pathBuffer);
}
const wstring NppShell::Helpers::GetApplicationPath()
{
path modulePath = GetModulePath();
return modulePath.parent_path().parent_path().wstring();
}
const wstring NppShell::Helpers::GetContextMenuPath()
{
path modulePath = GetModulePath();
return modulePath.parent_path().wstring();
}
const wstring NppShell::Helpers::GetContextMenuFullName()
{
path modulePath = GetModulePath();
return modulePath.wstring();
}
const wstring NppShell::Helpers::GetExecutingModuleName()
{
wchar_t pathBuffer[FILENAME_MAX] = { 0 };
GetModuleFileNameW(NULL, pathBuffer, FILENAME_MAX);
PathStripPathW(pathBuffer);
wstring moduleName(pathBuffer);
transform(moduleName.begin(), moduleName.end(), moduleName.begin(), towlower);
return moduleName;
}