mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-31 06:25:20 +00:00
Hosts file editor (#20462)
This commit is contained in:
committed by
GitHub
parent
ab41b61e84
commit
b2e1337d4e
@@ -1049,7 +1049,7 @@ UINT __stdcall CreateWinAppSDKHardlinksCA(MSIHANDLE hInstall)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
UINT er = ERROR_SUCCESS;
|
||||
std::wstring installationFolder, winAppSDKFilesSrcDir, settingsDir, powerRenameDir, measureToolDir;
|
||||
std::wstring installationFolder, winAppSDKFilesSrcDir, settingsDir, powerRenameDir, measureToolDir, hostsFileEditorDir;
|
||||
|
||||
hr = WcaInitialize(hInstall, "CreateWinAppSDKHardlinksCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
@@ -1058,6 +1058,7 @@ UINT __stdcall CreateWinAppSDKHardlinksCA(MSIHANDLE hInstall)
|
||||
ExitOnFailure(hr, "Failed to get installation folder");
|
||||
|
||||
winAppSDKFilesSrcDir = installationFolder + L"dll\\WinAppSDK\\";
|
||||
hostsFileEditorDir = installationFolder + L"modules\\Hosts\\";
|
||||
settingsDir = installationFolder + L"Settings\\";
|
||||
powerRenameDir = installationFolder + L"modules\\PowerRename\\";
|
||||
measureToolDir = installationFolder + L"modules\\MeasureTool\\";
|
||||
@@ -1065,6 +1066,7 @@ UINT __stdcall CreateWinAppSDKHardlinksCA(MSIHANDLE hInstall)
|
||||
for (auto file : winAppSdkFiles)
|
||||
{
|
||||
std::error_code ec;
|
||||
std::filesystem::create_hard_link((winAppSDKFilesSrcDir + file).c_str(), (hostsFileEditorDir + file).c_str(), ec);
|
||||
std::filesystem::create_hard_link((winAppSDKFilesSrcDir + file).c_str(), (settingsDir + file).c_str(), ec);
|
||||
std::filesystem::create_hard_link((winAppSDKFilesSrcDir + file).c_str(), (powerRenameDir + file).c_str(), ec);
|
||||
std::filesystem::create_hard_link((winAppSDKFilesSrcDir + file).c_str(), (measureToolDir + file).c_str(), ec);
|
||||
@@ -1088,7 +1090,7 @@ UINT __stdcall CreatePTInteropHardlinksCA(MSIHANDLE hInstall)
|
||||
HRESULT hr = S_OK;
|
||||
UINT er = ERROR_SUCCESS;
|
||||
std::wstring installationFolder, interopFilesSrcDir, colorPickerDir, powerOCRDir, launcherDir, fancyZonesDir,
|
||||
imageResizerDir, settingsDir, awakeDir, measureToolDir, powerAccentDir;
|
||||
imageResizerDir, settingsDir, awakeDir, measureToolDir, powerAccentDir, hostsFileEditorDir;
|
||||
|
||||
hr = WcaInitialize(hInstall, "CreatePTInteropHardlinksCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
@@ -1101,6 +1103,7 @@ UINT __stdcall CreatePTInteropHardlinksCA(MSIHANDLE hInstall)
|
||||
powerOCRDir = installationFolder + L"modules\\PowerOCR\\";
|
||||
launcherDir = installationFolder + L"modules\\launcher\\";
|
||||
fancyZonesDir = installationFolder + L"modules\\FancyZones\\";
|
||||
hostsFileEditorDir = installationFolder + L"modules\\Hosts\\";
|
||||
imageResizerDir = installationFolder + L"modules\\ImageResizer\\";
|
||||
settingsDir = installationFolder + L"Settings\\";
|
||||
awakeDir = installationFolder + L"modules\\Awake\\";
|
||||
@@ -1114,6 +1117,7 @@ UINT __stdcall CreatePTInteropHardlinksCA(MSIHANDLE hInstall)
|
||||
std::filesystem::create_hard_link((interopFilesSrcDir + file).c_str(), (powerOCRDir + file).c_str(), ec);
|
||||
std::filesystem::create_hard_link((interopFilesSrcDir + file).c_str(), (launcherDir + file).c_str(), ec);
|
||||
std::filesystem::create_hard_link((interopFilesSrcDir + file).c_str(), (fancyZonesDir + file).c_str(), ec);
|
||||
std::filesystem::create_hard_link((interopFilesSrcDir + file).c_str(), (hostsFileEditorDir + file).c_str(), ec);
|
||||
std::filesystem::create_hard_link((interopFilesSrcDir + file).c_str(), (imageResizerDir + file).c_str(), ec);
|
||||
std::filesystem::create_hard_link((interopFilesSrcDir + file).c_str(), (settingsDir + file).c_str(), ec);
|
||||
std::filesystem::create_hard_link((interopFilesSrcDir + file).c_str(), (awakeDir + file).c_str(), ec);
|
||||
@@ -1138,7 +1142,7 @@ UINT __stdcall DeleteWinAppSDKHardlinksCA(MSIHANDLE hInstall)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
UINT er = ERROR_SUCCESS;
|
||||
std::wstring installationFolder, settingsDir, powerRenameDir, measureToolDir;
|
||||
std::wstring installationFolder, settingsDir, powerRenameDir, measureToolDir, hostsFileEditorDir;
|
||||
|
||||
hr = WcaInitialize(hInstall, "DeleteWinAppSDKHardlinksCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
@@ -1146,6 +1150,7 @@ UINT __stdcall DeleteWinAppSDKHardlinksCA(MSIHANDLE hInstall)
|
||||
hr = getInstallFolder(hInstall, installationFolder);
|
||||
ExitOnFailure(hr, "Failed to get installation folder");
|
||||
|
||||
hostsFileEditorDir = installationFolder + L"modules\\Hosts\\";
|
||||
settingsDir = installationFolder + L"Settings\\";
|
||||
powerRenameDir = installationFolder + L"modules\\PowerRename\\";
|
||||
measureToolDir = installationFolder + L"modules\\MeasureTool\\";
|
||||
@@ -1154,6 +1159,7 @@ UINT __stdcall DeleteWinAppSDKHardlinksCA(MSIHANDLE hInstall)
|
||||
{
|
||||
for (auto file : winAppSdkFiles)
|
||||
{
|
||||
DeleteFile((hostsFileEditorDir + file).c_str());
|
||||
DeleteFile((settingsDir + file).c_str());
|
||||
DeleteFile((powerRenameDir + file).c_str());
|
||||
DeleteFile((measureToolDir + file).c_str());
|
||||
@@ -1178,7 +1184,7 @@ UINT __stdcall DeletePTInteropHardlinksCA(MSIHANDLE hInstall)
|
||||
HRESULT hr = S_OK;
|
||||
UINT er = ERROR_SUCCESS;
|
||||
std::wstring installationFolder, interopFilesSrcDir, colorPickerDir, powerOCRDir, launcherDir, fancyZonesDir,
|
||||
imageResizerDir, settingsDir, awakeDir, measureToolDir, powerAccentDir;
|
||||
imageResizerDir, settingsDir, awakeDir, measureToolDir, powerAccentDir, hostsFileEditorDir;
|
||||
|
||||
hr = WcaInitialize(hInstall, "DeletePTInteropHardlinksCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
@@ -1190,6 +1196,7 @@ UINT __stdcall DeletePTInteropHardlinksCA(MSIHANDLE hInstall)
|
||||
powerOCRDir = installationFolder + L"modules\\PowerOCR\\";
|
||||
launcherDir = installationFolder + L"modules\\launcher\\";
|
||||
fancyZonesDir = installationFolder + L"modules\\FancyZones\\";
|
||||
hostsFileEditorDir = installationFolder + L"modules\\Hosts\\";
|
||||
imageResizerDir = installationFolder + L"modules\\ImageResizer\\";
|
||||
settingsDir = installationFolder + L"Settings\\";
|
||||
awakeDir = installationFolder + L"modules\\Awake\\";
|
||||
@@ -1204,6 +1211,7 @@ UINT __stdcall DeletePTInteropHardlinksCA(MSIHANDLE hInstall)
|
||||
DeleteFile((powerOCRDir + file).c_str());
|
||||
DeleteFile((launcherDir + file).c_str());
|
||||
DeleteFile((fancyZonesDir + file).c_str());
|
||||
DeleteFile((hostsFileEditorDir + file).c_str());
|
||||
DeleteFile((imageResizerDir + file).c_str());
|
||||
DeleteFile((settingsDir + file).c_str());
|
||||
DeleteFile((awakeDir + file).c_str());
|
||||
|
Reference in New Issue
Block a user