sti: add launch application registry
Damjan Jovanovic
damjan.jov at gmail.com
Sun Jan 17 03:09:24 CST 2010
Changelog:
* sti: add launch application registry
Damjan Jovanovic
-------------- next part --------------
diff --git a/dlls/sti/sti.c b/dlls/sti/sti.c
index c88205d..1e33bc6 100644
--- a/dlls/sti/sti.c
+++ b/dlls/sti/sti.c
@@ -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 = RegOpenKeyExW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, 0, KEY_ALL_ACCESS, ®isteredAppsKey);
+ 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 = RegOpenKeyExW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, 0, KEY_ALL_ACCESS, ®isteredAppsKey);
+ 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,
diff --git a/dlls/sti/sti_private.h b/dlls/sti/sti_private.h
diff --git a/dlls/sti/tests/sti.c b/dlls/sti/tests/sti.c
index 0575d29..7c0f21e 100644
--- a/dlls/sti/tests/sti.c
+++ b/dlls/sti/tests/sti.c
@@ -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};
+
+ if (pStiCreateInstanceW)
+ {
+ IStillImageW *pStiW = NULL;
+ HRESULT hr;
+
+ 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);
+ }
+ else
+ skip("No StiCreateInstanceW function\n");
+}
+
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
diff --git a/tools/wine.inf.in b/tools/wine.inf.in
index e03a7e4..8b1b01b 100644
--- a/tools/wine.inf.in
+++ b/tools/wine.inf.in
@@ -387,6 +387,7 @@ HKLM,%CurrentVersion%\Controls Folder\PowerCfg,"LastID",,"5"
HKLM,%CurrentVersion%\RunServices,"winemenubuilder",2,"%11%\winemenubuilder.exe -a -r"
HKLM,%CurrentVersion%\Setup,"BootDir",,"%30%"
HKLM,%CurrentVersion%\Setup,"SharedDir",,"%25%"
+HKLM,%CurrentVersion%\StillImage\Registered Applications
HKLM,%CurrentVersion%\Uninstall,,,""
HKLM,%CurrentVersionNT%,"RegisteredOrganization",2,""
HKLM,%CurrentVersionNT%,"RegisteredOwner",2,""
More information about the wine-patches
mailing list