Skip to content

Commit

Permalink
Port fixes from PowerRename back to SmartRename.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrdavis committed May 26, 2021
1 parent 78c7c29 commit c02c293
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
4 changes: 2 additions & 2 deletions SmartRenameInstaller32/SmartRenameInstaller32.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@
"SearchPath" = "8:"
"UseSystemSearchPath" = "11:TRUE"
"TargetPlatform" = "3:0"
"PreBuildEvent" = "8:signtool sign /t http://timestamp.comodoca.com/authenticode /f %CERTPATH% /p %CERTPW% $(ProjectDir)..\\win32\\release\\SmartRenameExt32.dll"
"PostBuildEvent" = "8:signtool sign /t http://timestamp.comodoca.com/authenticode /f %CERTPATH% /p %CERTPW% $(ProjectDir)release\\SmartRenameInstaller32.msi\r\nsigntool sign /t http://timestamp.comodoca.com/authenticode /f %CERTPATH% /p %CERTPW% $(ProjectDir)release\\setup.exe"
"PreBuildEvent" = "8:"
"PostBuildEvent" = "8:"
"RunPostBuildEvent" = "3:0"
}
"Registry"
Expand Down
4 changes: 2 additions & 2 deletions SmartRenameInstaller64/SmartRenameInstaller64.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@
"SearchPath" = "8:"
"UseSystemSearchPath" = "11:TRUE"
"TargetPlatform" = "3:1"
"PreBuildEvent" = "8:signtool sign /t http://timestamp.comodoca.com/authenticode /f %CERTPATH% /p %CERTPW% $(ProjectDir)..\\x64\\release\\SmartRenameExt64.dll\r\nsigntool sign /t http://timestamp.comodoca.com/authenticode /f %CERTPATH% /p %CERTPW% $(ProjectDir)..\\win32\\release\\SmartRenameExt32.dll"
"PostBuildEvent" = "8:signtool sign /t http://timestamp.comodoca.com/authenticode /f %CERTPATH% /p %CERTPW% $(ProjectDir)release\\SmartRenameInstaller64.msi\r\nsigntool sign /t http://timestamp.comodoca.com/authenticode /f %CERTPATH% /p %CERTPW% $(ProjectDir)release\\setup.exe"
"PreBuildEvent" = "8:"
"PostBuildEvent" = "8:"
"RunPostBuildEvent" = "3:0"
}
"Registry"
Expand Down
2 changes: 1 addition & 1 deletion SmartRenameLib/SmartRenameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ DWORD CSmartRenameManager::_GetDefaultFileOpFlags()

DWORD WINAPI CSmartRenameManager::s_fileOpWorkerThread(_In_ void* pv)
{
if (SUCCEEDED(CoInitializeEx(NULL, 0)))
if (SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)))
{
WorkerThreadData* pwtd = reinterpret_cast<WorkerThreadData*>(pv);
if (pwtd)
Expand Down
29 changes: 23 additions & 6 deletions SmartRenameUI/SmartRenameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ void CSmartRenameUI::_Cleanup()
{
RevokeDragDrop(m_hwnd);
}

m_hwnd = NULL;
}

HRESULT CSmartRenameUI::_EnumerateItems(_In_ IDataObject* pdtobj)
Expand Down Expand Up @@ -1267,7 +1269,12 @@ HRESULT CSmartRenameProgressUI::Start()
{
_Cleanup();
m_canceled = false;
AddRef();
m_workerThreadHandle = CreateThread(nullptr, 0, s_workerThread, this, 0, nullptr);
if (!m_workerThreadHandle)
{
Release();
}
return (m_workerThreadHandle) ? S_OK : E_FAIL;
}

Expand All @@ -1282,20 +1289,22 @@ DWORD WINAPI CSmartRenameProgressUI::s_workerThread(_In_ void* pv)

SetTimer(hwndMessage, TIMERID_CHECKCANCELED, CANCEL_CHECK_INTERVAL, nullptr);

if (SUCCEEDED(CoCreateInstance(CLSID_ProgressDialog, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&pThis->m_sppd))))
CComPtr<IProgressDialog> sppd;
if (SUCCEEDED(CoCreateInstance(CLSID_ProgressDialog, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&sppd))))
{
pThis->m_sppd = sppd;
wchar_t buff[100] = { 0 };
LoadString(g_hInst, IDS_LOADING, buff, ARRAYSIZE(buff));
pThis->m_sppd->SetLine(1, buff, FALSE, NULL);
sppd->SetLine(1, buff, FALSE, NULL);
LoadString(g_hInst, IDS_LOADING_MSG, buff, ARRAYSIZE(buff));
pThis->m_sppd->SetLine(2, buff, FALSE, NULL);
sppd->SetLine(2, buff, FALSE, NULL);
LoadString(g_hInst, IDS_APP_TITLE, buff, ARRAYSIZE(buff));
pThis->m_sppd->SetTitle(buff);
sppd->SetTitle(buff);
SetTimer(hwndMessage, TIMERID_CHECKCANCELED, CANCEL_CHECK_INTERVAL, nullptr);
pThis->m_sppd->StartProgressDialog(NULL, NULL, PROGDLG_MARQUEEPROGRESS, NULL);
sppd->StartProgressDialog(NULL, NULL, PROGDLG_MARQUEEPROGRESS, NULL);
}

while (pThis->m_sppd && !pThis->m_canceled)
while (pThis->m_sppd && !sppd->HasUserCancelled())
{
MSG msg;
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
Expand All @@ -1305,8 +1314,13 @@ DWORD WINAPI CSmartRenameProgressUI::s_workerThread(_In_ void* pv)
}
}

// Ensure dialog is stopped
sppd->StopProgressDialog();

KillTimer(hwndMessage, TIMERID_CHECKCANCELED);
DestroyWindow(hwndMessage);

pThis->Release();
}

CoUninitialize();
Expand All @@ -1331,6 +1345,8 @@ void CSmartRenameProgressUI::_Cleanup()

if (m_workerThreadHandle)
{
// Wait for up to 5 seconds for worker thread to finish
WaitForSingleObject(m_workerThreadHandle, 5000);
CloseHandle(m_workerThreadHandle);
m_workerThreadHandle = nullptr;
}
Expand Down Expand Up @@ -1378,6 +1394,7 @@ LRESULT CSmartRenameProgressUI::_WndProc(_In_ HWND hwnd, _In_ UINT msg, _In_ WPA
break;

case WM_DESTROY:
_UpdateCancelState();
KillTimer(hwnd, TIMERID_CHECKCANCELED);
break;

Expand Down

0 comments on commit c02c293

Please sign in to comment.