mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[platform] making Windows launcher check and set path variables (AppData/LocalAppData)
GitOrigin-RevId: f693a7f10a206135df486e4c590bd0ad27ac57d4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4829584d9f
commit
d1cee35b46
Executable → Regular
BIN
Binary file not shown.
Executable → Regular
BIN
Binary file not shown.
@@ -1165,6 +1165,20 @@ std::wstring GetCurrentDirectoryAsString()
|
||||
return std::wstring(buffer.data(), sizeWithoutTerminatingZero);
|
||||
}
|
||||
|
||||
static void SetPathVariable(const wchar_t *varName, REFKNOWNFOLDERID rfId)
|
||||
{
|
||||
wchar_t env_var_buffer[1];
|
||||
if (GetEnvironmentVariableW(varName, env_var_buffer, 1) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
|
||||
{
|
||||
wchar_t *path = NULL;
|
||||
if (SHGetKnownFolderPath(rfId, KF_FLAG_DONT_VERIFY, NULL, &path) == S_OK)
|
||||
{
|
||||
SetEnvironmentVariableW(varName, path);
|
||||
CoTaskMemFree(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPTSTR lpCmdLine,
|
||||
@@ -1187,6 +1201,10 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ensures path variables are defined
|
||||
SetPathVariable(L"APPDATA", FOLDERID_RoamingAppData);
|
||||
SetPathVariable(L"LOCALAPPDATA", FOLDERID_LocalAppData);
|
||||
|
||||
//it's OK to return 0 here, because the control is transferred to the first instance
|
||||
int exitCode = CheckSingleInstance();
|
||||
if (exitCode != -1) return exitCode;
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
#include <Windows.h>
|
||||
#include <ShellAPI.h>
|
||||
#include <Shlobj.h>
|
||||
#include <Knownfolders.h>
|
||||
|
||||
// C RunTime Header Files
|
||||
#include <stdio.h>
|
||||
@@ -24,5 +26,3 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
Reference in New Issue
Block a user