sti: Add launch application registry.

This commit is contained in:
Damjan Jovanovic 2010-01-18 21:29:26 +02:00 committed by Alexandre Julliard
parent ac1ad1372d
commit 226998185f
2 changed files with 87 additions and 4 deletions

View File

@ -31,9 +31,19 @@
#include "sti_private.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(sti);
static const WCHAR registeredAppsLaunchPath[] = {
'S','O','F','T','W','A','R','E','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'S','t','i','l','l','I','m','a','g','e','\\',
'R','e','g','i','s','t','e','r','e','d',' ','A','p','p','l','i','c','a','t','i','o','n','s',0
};
static inline stillimage *impl_from_StillImageW(IStillImageW *iface)
{
return (stillimage *)((char*)iface - FIELD_OFFSET(stillimage, lpVtbl));
@ -119,16 +129,60 @@ static HRESULT WINAPI stillimagew_GetSTILaunchInformation(IStillImageW *iface, L
static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName,
LPWSTR pwszCommandLine)
{
static const WCHAR format[] = {'%','s',' ','%','s',0};
static const WCHAR commandLineSuffix[] = {
'/','S','t','i','D','e','v','i','c','e',':','%','1',' ',
'/','S','t','i','E','v','e','n','t',':','%','2',0};
HKEY registeredAppsKey = NULL;
DWORD ret;
HRESULT hr = S_OK;
stillimage *This = impl_from_StillImageW(iface);
FIXME("(%p, %s, %s): stub\n", This, debugstr_w(pwszAppName), debugstr_w(pwszCommandLine));
return E_NOTIMPL;
TRACE("(%p, %s, %s)\n", This, debugstr_w(pwszAppName), debugstr_w(pwszCommandLine));
ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, &registeredAppsKey);
if (ret == ERROR_SUCCESS)
{
WCHAR *value = HeapAlloc(GetProcessHeap(), 0,
(lstrlenW(pwszCommandLine) + 1 + lstrlenW(commandLineSuffix) + 1) * sizeof(WCHAR));
if (value)
{
sprintfW(value, format, pwszCommandLine, commandLineSuffix);
ret = RegSetValueExW(registeredAppsKey, pwszAppName, 0,
REG_SZ, (BYTE*)value, (lstrlenW(value)+1)*sizeof(WCHAR));
if (ret != ERROR_SUCCESS)
hr = HRESULT_FROM_WIN32(ret);
HeapFree(GetProcessHeap(), 0, value);
}
else
hr = E_OUTOFMEMORY;
RegCloseKey(registeredAppsKey);
}
else
hr = HRESULT_FROM_WIN32(ret);
return hr;
}
static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName)
{
stillimage *This = impl_from_StillImageW(iface);
FIXME("(%p, %s): stub\n", This, debugstr_w(pwszAppName));
return S_OK;
HKEY registeredAppsKey = NULL;
DWORD ret;
HRESULT hr = S_OK;
TRACE("(%p, %s)\n", This, debugstr_w(pwszAppName));
ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, &registeredAppsKey);
if (ret == ERROR_SUCCESS)
{
ret = RegDeleteValueW(registeredAppsKey, pwszAppName);
if (ret != ERROR_SUCCESS)
hr = HRESULT_FROM_WIN32(ret);
RegCloseKey(registeredAppsKey);
}
else
hr = HRESULT_FROM_WIN32(ret);
return hr;
}
static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPCWSTR pwszDeviceName,

View File

@ -228,6 +228,34 @@ static void test_stillimage_aggregation(void)
skip("No StiCreateInstanceW function\n");
}
static void test_launch_app_registry(void)
{
static WCHAR appName[] = {'w','i','n','e','s','t','i','t','e','s','t','a','p','p',0};
IStillImageW *pStiW = NULL;
HRESULT hr;
if (pStiCreateInstanceW == NULL)
{
win_skip("No StiCreateInstanceW function\n");
return;
}
hr = pStiCreateInstance(GetModuleHandle(NULL), STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE, &pStiW, NULL);
if (SUCCEEDED(hr))
{
hr = IStillImage_RegisterLaunchApplication(pStiW, appName, appName);
ok(SUCCEEDED(hr), "could not register launch application, error 0x%X\n", hr);
if (SUCCEEDED(hr))
{
hr = IStillImage_UnregisterLaunchApplication(pStiW, appName);
ok(SUCCEEDED(hr), "could not unregister launch application, error 0x%X\n", hr);
}
IStillImage_Release(pStiW);
}
else
ok(0, "could not create StillImageW, hr = 0x%X\n", hr);
}
START_TEST(sti)
{
if (SUCCEEDED(CoInitialize(NULL)))
@ -236,6 +264,7 @@ START_TEST(sti)
{
test_version_flag_versus_aw();
test_stillimage_aggregation();
test_launch_app_registry();
FreeLibrary(sti_dll);
}
else