mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-23 15:09:41 +01:00
* Add project
* Cleanup project file and add resource file
* Move common logic to FileLocksmithLib
* Cleanup interop vcxproj
* Implement handler, add assets and appx manifest
* Revert "Cleanup interop vcxproj"
This reverts commit 97bf991f2e.
* Remove package on uninstall
Install package on enable
Fix launching app
Cleanup
* Revert non-related change
* Spellcheck
* Update src/modules/FileLocksmith/FileLocksmithContextMenu/Resources.resx
* Wire Show in extended context menu setting
63 lines
1.2 KiB
C++
63 lines
1.2 KiB
C++
#include "pch.h"
|
|
|
|
#include "IPC.h"
|
|
#include "Constants.h"
|
|
|
|
#include <common/SettingsAPI/settings_helpers.h>
|
|
|
|
constexpr DWORD DefaultPipeBufferSize = 8192;
|
|
constexpr DWORD DefaultPipeTimeoutMillis = 200;
|
|
|
|
namespace ipc
|
|
{
|
|
Writer::Writer()
|
|
{
|
|
start();
|
|
}
|
|
|
|
Writer::~Writer()
|
|
{
|
|
finish();
|
|
}
|
|
|
|
HRESULT Writer::start()
|
|
{
|
|
std::wstring path = PTSettingsHelper::get_module_save_folder_location(constants::nonlocalizable::PowerToyName);
|
|
path += L"\\";
|
|
path += constants::nonlocalizable::LastRunPath;
|
|
|
|
try
|
|
{
|
|
m_stream = std::ofstream(path);
|
|
return S_OK;
|
|
}
|
|
catch (...)
|
|
{
|
|
return E_FAIL;
|
|
}
|
|
}
|
|
|
|
HRESULT Writer::add_path(LPCWSTR path)
|
|
{
|
|
int length = lstrlenW(path);
|
|
if (!m_stream.write(reinterpret_cast<const char*>(path), length * sizeof(WCHAR)))
|
|
{
|
|
return E_FAIL;
|
|
}
|
|
|
|
WCHAR line_break = L'\n';
|
|
if (!m_stream.write(reinterpret_cast<const char*>(&line_break), sizeof(WCHAR)))
|
|
{
|
|
return E_FAIL;
|
|
}
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
void Writer::finish()
|
|
{
|
|
add_path(L"");
|
|
m_stream.close();
|
|
}
|
|
}
|