mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-26 16:19:08 +08:00
Get USER_PROFILE differently
USER_PROFILE is a known folder, so use that functionality to get it.
This commit is contained in:
parent
73e1eb2a8b
commit
c055ce1c13
@ -3,6 +3,8 @@
|
|||||||
#include <Shlwapi.h>
|
#include <Shlwapi.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <Shlobj.h>
|
||||||
|
|
||||||
|
|
||||||
#pragma comment(lib, "Shlwapi.lib")
|
#pragma comment(lib, "Shlwapi.lib")
|
||||||
|
|
||||||
@ -156,13 +158,18 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
|||||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||||
if (!streqi(path.c_str(), L""))
|
if (!streqi(path.c_str(), L""))
|
||||||
{
|
{
|
||||||
SetEnvironmentVariable(L"CMDER_START", path.c_str());
|
if (!SetEnvironmentVariable(L"CMDER_START", path.c_str())) {
|
||||||
|
MessageBox(NULL, _T("Error trying to set CMDER_START to given path!"), _T("Error"), MB_OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
static wchar_t buff[MAX_PATH] = { 0 };
|
wchar_t* homeProfile = 0;
|
||||||
GetEnvironmentVariable(L"USER_PROFILE", buff, MAX_PATH);
|
SHGetKnownFolderPath(FOLDERID_Profile, 0, NULL, &homeProfile);
|
||||||
SetEnvironmentVariable(L"CMDER_START", buff);
|
if (!SetEnvironmentVariable(L"CMDER_START", homeProfile)) {
|
||||||
|
MessageBox(NULL, _T("Error trying to set CMDER_START to USER_PROFILE!"), _T("Error"), MB_OK);
|
||||||
|
}
|
||||||
|
CoTaskMemFree(static_cast<void*>(homeProfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure EnvironmentVariables are propagated.
|
// Ensure EnvironmentVariables are propagated.
|
||||||
@ -177,8 +184,10 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
|
if (!CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) {
|
||||||
CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
|
MessageBox(NULL, _T("Unable to create the ConEmu Process!"), _T("Error"), MB_OK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsUserOnly(std::wstring opt)
|
bool IsUserOnly(std::wstring opt)
|
||||||
|
Loading…
Reference in New Issue
Block a user