2019-10-18 05:57:19 +02:00
|
|
|
// PowerRenameTest.cpp : Defines the entry point for the application.
|
|
|
|
//
|
|
|
|
|
2020-04-29 22:02:18 +02:00
|
|
|
#include "pch.h"
|
2019-10-18 05:57:19 +02:00
|
|
|
#include "PowerRenameTest.h"
|
|
|
|
#include <PowerRenameInterfaces.h>
|
|
|
|
#include <PowerRenameItem.h>
|
|
|
|
#include <PowerRenameManager.h>
|
|
|
|
#include <Shobjidl.h>
|
2021-10-25 15:40:19 +02:00
|
|
|
#include <atlfile.h>
|
|
|
|
#include <atlstr.h>
|
|
|
|
|
|
|
|
#include <common/utils/process_path.h>
|
2019-10-18 05:57:19 +02:00
|
|
|
|
2019-12-20 14:59:20 +01:00
|
|
|
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
2019-10-18 05:57:19 +02:00
|
|
|
|
2021-10-25 15:40:19 +02:00
|
|
|
HINSTANCE g_hostHInst;
|
2019-12-19 10:15:54 +01:00
|
|
|
void ModuleAddRef() {}
|
|
|
|
void ModuleRelease() {}
|
2019-10-18 05:57:19 +02:00
|
|
|
|
|
|
|
// {0440049F-D1DC-4E46-B27B-98393D79486B}
|
|
|
|
//DEFINE_GUID(CLSID_PowerRenameMenu, 0x0440049F, 0xD1DC, 0x4E46, 0xB2, 0x7B, 0x98, 0x39, 0x3D, 0x79, 0x48, 0x6B);
|
|
|
|
|
|
|
|
class __declspec(uuid("{0440049F-D1DC-4E46-B27B-98393D79486B}")) Foo;
|
|
|
|
static const CLSID CLSID_PowerRenameMenu = __uuidof(Foo);
|
|
|
|
|
|
|
|
DEFINE_GUID(BHID_DataObject, 0xb8c0bd9f, 0xed24, 0x455c, 0x83, 0xe6, 0xd5, 0x39, 0xc, 0x4f, 0xe8, 0xc4);
|
|
|
|
|
|
|
|
int APIENTRY wWinMain(
|
|
|
|
_In_ HINSTANCE hInstance,
|
|
|
|
_In_opt_ HINSTANCE hPrevInstance,
|
|
|
|
_In_ PWSTR lpCmdLine,
|
|
|
|
_In_ int nCmdShow)
|
|
|
|
{
|
2021-10-25 15:40:19 +02:00
|
|
|
g_hostHInst = hInstance;
|
2019-10-18 05:57:19 +02:00
|
|
|
HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2021-10-25 15:40:19 +02:00
|
|
|
// Set the application path based on the location of the dll
|
|
|
|
std::wstring path = get_module_folderpath(g_hostHInst);
|
|
|
|
path = path + L"\\PowerRename.exe";
|
|
|
|
LPTSTR lpApplicationName = (LPTSTR)path.c_str();
|
|
|
|
|
|
|
|
CString commandLine;
|
|
|
|
commandLine.Format(_T("\"%s\""), lpApplicationName);
|
|
|
|
|
|
|
|
int nSize = commandLine.GetLength() + 1;
|
|
|
|
LPTSTR lpszCommandLine = new TCHAR[nSize];
|
|
|
|
_tcscpy_s(lpszCommandLine, nSize, commandLine);
|
|
|
|
|
|
|
|
STARTUPINFO startupInfo;
|
|
|
|
ZeroMemory(&startupInfo, sizeof(STARTUPINFO));
|
|
|
|
startupInfo.cb = sizeof(STARTUPINFO);
|
|
|
|
startupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
|
|
|
|
startupInfo.wShowWindow = SW_SHOWNORMAL;
|
2019-10-18 05:57:19 +02:00
|
|
|
|
2021-10-25 15:40:19 +02:00
|
|
|
PROCESS_INFORMATION processInformation;
|
|
|
|
|
|
|
|
// Start the resizer
|
|
|
|
CreateProcess(
|
|
|
|
NULL,
|
|
|
|
lpszCommandLine,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
TRUE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&startupInfo,
|
|
|
|
&processInformation);
|
|
|
|
delete[] lpszCommandLine;
|
|
|
|
if (!CloseHandle(processInformation.hProcess))
|
|
|
|
{
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
if (!CloseHandle(processInformation.hThread))
|
|
|
|
{
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
return hr;
|
2019-10-18 05:57:19 +02:00
|
|
|
}
|
|
|
|
CoUninitialize();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|