mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-03-07 17:36:52 +08:00
Replace 'PathAppend' with 'MyPathAppend'
This commit is contained in:
parent
8909224a13
commit
aafe7f44e7
@ -88,18 +88,17 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
|
|
||||||
std::wstring hmclJavaDir;
|
std::wstring hmclJavaDir;
|
||||||
{
|
{
|
||||||
WCHAR buffer[MAX_PATH];
|
std::wstring buffer;
|
||||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, buffer))
|
if (SUCCEEDED(MySHGetFolderPath(CSIDL_APPDATA, buffer)) || SUCCEEDED(MySHGetFolderPath(CSIDL_PROFILE, buffer))) {
|
||||||
|| SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, 0, buffer))) {
|
MyPathAppend(buffer, L".hmcl");
|
||||||
PathAppend(buffer, L".hmcl");
|
MyPathAppend(buffer, L"java");
|
||||||
PathAppend(buffer, L"java");
|
|
||||||
if (isX64) {
|
if (isX64) {
|
||||||
PathAppend(buffer, L"windows-x86_64");
|
MyPathAppend(buffer, L"windows-x86_64");
|
||||||
} else {
|
} else {
|
||||||
PathAppend(buffer, L"windows-x86");
|
MyPathAppend(buffer, L"windows-x86");
|
||||||
}
|
}
|
||||||
PathAddBackslash(buffer);
|
MyPathAddBackslash(buffer);
|
||||||
hmclJavaDir = std::wstring(buffer);
|
hmclJavaDir = buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +121,12 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
|
|
||||||
// Try downloading Java on Windows 7 or later
|
// Try downloading Java on Windows 7 or later
|
||||||
if (VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask)) {
|
if (VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask)) {
|
||||||
// TODO
|
HRSRC scriptFileResource = FindResource(NULL, MAKEINTRESOURCE(ID_SCRIPT_DOWNLOAD_JAVA), RT_RCDATA);
|
||||||
|
if (scriptFileResource) {
|
||||||
|
HGLOBAL scriptHandle = LoadResource(NULL, scriptFileResource);
|
||||||
|
DWORD dataSize = SizeofResource(NULL, scriptFileResource);
|
||||||
|
void *data = LockResource(scriptHandle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,3 +97,30 @@ bool MyGetFileVersionInfo(const std::wstring &filePath, Version &version) {
|
|||||||
(pFileInfo->dwFileVersionLS >> 0) & 0xFFFF};
|
(pFileInfo->dwFileVersionLS >> 0) & 0xFFFF};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT MySHGetFolderPath(int csidl, std::wstring &out) {
|
||||||
|
out = std::wstring();
|
||||||
|
out.resize(MAX_PATH);
|
||||||
|
|
||||||
|
HRESULT res = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, &out[0]);
|
||||||
|
if (SUCCEEDED(res)) {
|
||||||
|
out.resize(wcslen(&out[0]));
|
||||||
|
} else {
|
||||||
|
out.resize(0);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyPathAppend(std::wstring &filePath, const std::wstring &more) {
|
||||||
|
if (filePath.back() != L'\\') {
|
||||||
|
filePath += L'\\';
|
||||||
|
}
|
||||||
|
|
||||||
|
filePath += more;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyPathAddBackslash(std::wstring &filePath) {
|
||||||
|
if (filePath.back() != L'\\') {
|
||||||
|
filePath += L'\\';
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <shlobj.h>
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
|
|
||||||
const int MAX_KEY_LENGTH = 255;
|
const int MAX_KEY_LENGTH = 255;
|
||||||
@ -24,4 +25,10 @@ bool MyCreateProcess(const std::wstring &command, const std::wstring &workdir);
|
|||||||
// Check if file lpPath exists.
|
// Check if file lpPath exists.
|
||||||
bool FindFirstFileExists(LPCWSTR lpPath, DWORD dwFilter);
|
bool FindFirstFileExists(LPCWSTR lpPath, DWORD dwFilter);
|
||||||
|
|
||||||
bool MyGetFileVersionInfo(const std::wstring &filePath, Version &version);
|
bool MyGetFileVersionInfo(const std::wstring &filePath, Version &version);
|
||||||
|
|
||||||
|
HRESULT MySHGetFolderPath(int csidl, std::wstring &out);
|
||||||
|
|
||||||
|
void MyPathAppend(std::wstring &filePath, const std::wstring &more);
|
||||||
|
|
||||||
|
void MyPathAddBackslash(std::wstring &filePath);
|
Loading…
Reference in New Issue
Block a user