[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Politely terminating TSVNCache.exe?

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: 2006-07-27 20:02:53 CEST

Thomas Hruska wrote:
> What would you consider to be a "polite" method of terminating
> TSVNCache.exe?
>
> HWND TempHwnd = FindWindow("TSVNCacheWindow", "TSVNCacheWindow");
> if (TempHwnd != NULL) SendMessage(TempHwnd, WM_CLOSE, 0, 0);

Here's what we do in our custom action in the installer:

UINT __stdcall TerminateCache(MSIHANDLE hModule)
{
        HWND hWnd = FindWindow(TSVN_CACHE_WINDOW_NAME, TSVN_CACHE_WINDOW_NAME);
        if (hWnd)
        {
                // First, delete the registry key telling the shell where to find
                // the cache. This is to make sure that the cache won't be started
                // again right after we close it.
                HKEY hKey = 0;
                if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\TortoiseSVN"), 0,
KEY_WRITE, &hKey)==ERROR_SUCCESS)
                {
                        RegDeleteValue(hKey, _T("CachePath"));
                        RegCloseKey(hKey);
                }
                PostMessage(hWnd, WM_CLOSE, NULL, NULL);
                for (int i=0; i<10; ++i)
                {
                        Sleep(500);
                        if (!IsWindow(hWnd))
                        {
                                // Cache is gone!
                                return ERROR_SUCCESS;
                        }
                }
                // Don't return ERROR_FUNCTION_FAILED, because even if the cache is still
                // running, the installer will overwrite the file, and we require a
                // reboot anyway after upgrading.
                return ERROR_SUCCESS;
        }
        // cache wasn't even running
        return ERROR_SUCCESS;
}

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.tigris.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Thu Jul 27 20:03:06 2006

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.