mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Tweaks.
This commit is contained in:
parent
dfd53fb158
commit
852163bf68
@ -957,22 +957,14 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
|
|||||||
std::wstring command = Rainmeter->GetSkinPath() + m_SkinName;
|
std::wstring command = Rainmeter->GetSkinPath() + m_SkinName;
|
||||||
command += L"\\";
|
command += L"\\";
|
||||||
command += m_FileName;
|
command += m_FileName;
|
||||||
HANDLE file = CreateFile(command.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
bool writable = CSystem::IsFileWritable(command.c_str());
|
||||||
|
|
||||||
command.insert(0, L" \"");
|
command.insert(0, L" \"");
|
||||||
command.insert(0, Rainmeter->GetConfigEditor());
|
command.insert(0, Rainmeter->GetConfigEditor());
|
||||||
command += L"\"";
|
command += L"\"";
|
||||||
|
|
||||||
if (file == INVALID_HANDLE_VALUE)
|
// Execute as admin if in protected location
|
||||||
{
|
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL, !writable);
|
||||||
// File is in protected location, so execute as admin
|
|
||||||
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL, L"runas");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CloseHandle(file);
|
|
||||||
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1746,7 +1738,7 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
WCHAR buffer[16];
|
WCHAR buffer[16];
|
||||||
int sel = ComboBox_GetCurSel((HWND)lParam);
|
int sel = ComboBox_GetCurSel((HWND)lParam);
|
||||||
LCID lcid = ComboBox_GetItemData((HWND)lParam, sel);
|
LCID lcid = (LCID)ComboBox_GetItemData((HWND)lParam, sel);
|
||||||
_ultow(lcid, buffer, 10);
|
_ultow(lcid, buffer, 10);
|
||||||
WritePrivateProfileString(L"Rainmeter", L"Language", buffer, Rainmeter->GetIniFile().c_str());
|
WritePrivateProfileString(L"Rainmeter", L"Language", buffer, Rainmeter->GetIniFile().c_str());
|
||||||
|
|
||||||
|
@ -3143,17 +3143,7 @@ void CRainmeter::SetDisableVersionCheck(bool check)
|
|||||||
|
|
||||||
void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
|
void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
|
||||||
{
|
{
|
||||||
WritePrivateProfileString(L"Rainmeter", L"WriteTest", L"TRUE", m_IniFile.c_str());
|
if (!CSystem::IsFileWritable(m_IniFile.c_str()))
|
||||||
WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str()); // FLUSH
|
|
||||||
|
|
||||||
WCHAR tmpSz[5];
|
|
||||||
bool bSuccess = (GetPrivateProfileString(L"Rainmeter", L"WriteTest", L"", tmpSz, 5, m_IniFile.c_str()) > 0);
|
|
||||||
if (bSuccess)
|
|
||||||
{
|
|
||||||
bSuccess = (wcscmp(L"TRUE", tmpSz) == 0);
|
|
||||||
WritePrivateProfileString(L"Rainmeter", L"WriteTest", NULL, m_IniFile.c_str());
|
|
||||||
}
|
|
||||||
if (!bSuccess)
|
|
||||||
{
|
{
|
||||||
std::wstring error = GetString(ID_STR_SETTINGSNOTWRITABLE);
|
std::wstring error = GetString(ID_STR_SETTINGSNOTWRITABLE);
|
||||||
|
|
||||||
|
@ -1034,6 +1034,24 @@ ULONGLONG CSystem::GetTickCount64()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** IsFileWritable
|
||||||
|
**
|
||||||
|
** Checks if file is writable.
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
bool CSystem::IsFileWritable(LPCWSTR file)
|
||||||
|
{
|
||||||
|
HANDLE hFile = CreateFile(file, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(hFile);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** RmLoadLibrary
|
** RmLoadLibrary
|
||||||
**
|
**
|
||||||
|
@ -76,6 +76,8 @@ public:
|
|||||||
static bool IsUNCPath(const std::wstring& path) { return (path.length() >= 2 && IsPathSeparator(path[0]) && IsPathSeparator(path[1])); }
|
static bool IsUNCPath(const std::wstring& path) { return (path.length() >= 2 && IsPathSeparator(path[0]) && IsPathSeparator(path[1])); }
|
||||||
static bool IsAbsolutePath(const std::wstring& path) { return (path.find(L":\\") != std::wstring::npos || path.find(L":/") != std::wstring::npos || IsUNCPath(path)); }
|
static bool IsAbsolutePath(const std::wstring& path) { return (path.find(L":\\") != std::wstring::npos || path.find(L":/") != std::wstring::npos || IsUNCPath(path)); }
|
||||||
|
|
||||||
|
static bool IsFileWritable(LPCWSTR file);
|
||||||
|
|
||||||
static HMODULE RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError = NULL, bool ignoreErrors = false);
|
static HMODULE RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError = NULL, bool ignoreErrors = false);
|
||||||
static void ResetWorkingDirectory();
|
static void ResetWorkingDirectory();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user