netkvm: make code for getting module path reusable
@@ -259,11 +259,7 @@ public:
}
bool Install()
{
- CString s;
- HMODULE hModule = GetModuleHandleW(NULL);
- WCHAR path[MAX_PATH];
- GetModuleFileName(hModule, path, MAX_PATH);
- s = path;
+ CString s = BinaryPath();
CServiceManager mgr;
bool b = mgr.Install(ServiceName(), s);
return b;
@@ -283,6 +279,15 @@ public:
{
return m_Registered;
}
+ CString BinaryPath()
+ {
+ CString s;
+ HMODULE hModule = GetModuleHandle(NULL);
+ WCHAR path[MAX_PATH];
+ GetModuleFileName(hModule, path, MAX_PATH);
+ s = path;
+ return s;
+ }
protected:
CString m_Name;
HANDLE m_StopEvent = NULL;
