2 * Copyright (C) 2002 Aric Stewart for CodeWeavers
3 * Copyright (C) 2009 Damjan Jovanovic
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "sti_private.h"
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(sti);
38 static const WCHAR registeredAppsLaunchPath[] = {
39 'S','O','F','T','W','A','R','E','\\',
40 'M','i','c','r','o','s','o','f','t','\\',
41 'W','i','n','d','o','w','s','\\',
42 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
43 'S','t','i','l','l','I','m','a','g','e','\\',
44 'R','e','g','i','s','t','e','r','e','d',' ','A','p','p','l','i','c','a','t','i','o','n','s',0
47 static inline stillimage *impl_from_StillImageW(IStillImageW *iface)
49 return (stillimage *)((char*)iface - FIELD_OFFSET(stillimage, lpVtbl));
52 static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID riid, void **ppvObject)
54 stillimage *This = impl_from_StillImageW(iface);
55 TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
56 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
59 static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface)
61 stillimage *This = impl_from_StillImageW(iface);
62 return IUnknown_AddRef(This->pUnkOuter);
65 static ULONG WINAPI stillimagew_Release(IStillImageW *iface)
67 stillimage *This = impl_from_StillImageW(iface);
68 return IUnknown_Release(This->pUnkOuter);
71 static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hinst, DWORD dwVersion)
73 stillimage *This = impl_from_StillImageW(iface);
74 TRACE("(%p, %p, 0x%X)\n", This, hinst, dwVersion);
78 static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwType, DWORD dwFlags,
79 DWORD *pdwItemsReturned, LPVOID *ppBuffer)
81 stillimage *This = impl_from_StillImageW(iface);
82 FIXME("(%p, %u, 0x%X, %p, %p): stub\n", This, dwType, dwFlags, pdwItemsReturned, ppBuffer);
86 static HRESULT WINAPI stillimagew_GetDeviceInfo(IStillImageW *iface, LPWSTR pwszDeviceName,
89 stillimage *This = impl_from_StillImageW(iface);
90 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), ppBuffer);
94 static HRESULT WINAPI stillimagew_CreateDevice(IStillImageW *iface, LPWSTR pwszDeviceName, DWORD dwMode,
95 PSTIDEVICEW *pDevice, LPUNKNOWN pUnkOuter)
97 stillimage *This = impl_from_StillImageW(iface);
98 FIXME("(%p, %s, %u, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), dwMode, pDevice, pUnkOuter);
102 static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
103 LPDWORD pType, LPBYTE pData, LPDWORD cbData)
105 stillimage *This = impl_from_StillImageW(iface);
106 FIXME("(%p, %s, %s, %p, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
107 pType, pData, cbData);
111 static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
112 DWORD type, LPBYTE pData, DWORD cbData)
114 stillimage *This = impl_from_StillImageW(iface);
115 FIXME("(%p, %s, %s, %u, %p, %u): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
116 type, pData, cbData);
120 static HRESULT WINAPI stillimagew_GetSTILaunchInformation(IStillImageW *iface, LPWSTR pwszDeviceName,
121 DWORD *pdwEventCode, LPWSTR pwszEventName)
123 stillimage *This = impl_from_StillImageW(iface);
124 FIXME("(%p, %p, %p, %p): stub\n", This, pwszDeviceName,
125 pdwEventCode, pwszEventName);
129 static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName,
130 LPWSTR pwszCommandLine)
132 static const WCHAR format[] = {'%','s',' ','%','s',0};
133 static const WCHAR commandLineSuffix[] = {
134 '/','S','t','i','D','e','v','i','c','e',':','%','1',' ',
135 '/','S','t','i','E','v','e','n','t',':','%','2',0};
136 HKEY registeredAppsKey = NULL;
139 stillimage *This = impl_from_StillImageW(iface);
141 TRACE("(%p, %s, %s)\n", This, debugstr_w(pwszAppName), debugstr_w(pwszCommandLine));
143 ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, ®isteredAppsKey);
144 if (ret == ERROR_SUCCESS)
146 WCHAR *value = HeapAlloc(GetProcessHeap(), 0,
147 (lstrlenW(pwszCommandLine) + 1 + lstrlenW(commandLineSuffix) + 1) * sizeof(WCHAR));
150 sprintfW(value, format, pwszCommandLine, commandLineSuffix);
151 ret = RegSetValueExW(registeredAppsKey, pwszAppName, 0,
152 REG_SZ, (BYTE*)value, (lstrlenW(value)+1)*sizeof(WCHAR));
153 if (ret != ERROR_SUCCESS)
154 hr = HRESULT_FROM_WIN32(ret);
155 HeapFree(GetProcessHeap(), 0, value);
159 RegCloseKey(registeredAppsKey);
162 hr = HRESULT_FROM_WIN32(ret);
166 static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName)
168 stillimage *This = impl_from_StillImageW(iface);
169 HKEY registeredAppsKey = NULL;
173 TRACE("(%p, %s)\n", This, debugstr_w(pwszAppName));
175 ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, ®isteredAppsKey);
176 if (ret == ERROR_SUCCESS)
178 ret = RegDeleteValueW(registeredAppsKey, pwszAppName);
179 if (ret != ERROR_SUCCESS)
180 hr = HRESULT_FROM_WIN32(ret);
181 RegCloseKey(registeredAppsKey);
184 hr = HRESULT_FROM_WIN32(ret);
188 static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPCWSTR pwszDeviceName,
191 stillimage *This = impl_from_StillImageW(iface);
192 FIXME("(%p, %s, %u): stub\n", This, debugstr_w(pwszDeviceName), bNewState);
196 static HRESULT WINAPI stillimagew_GetHwNotificationState(IStillImageW *iface, LPCWSTR pwszDeviceName,
197 BOOL *pbCurrentState)
199 stillimage *This = impl_from_StillImageW(iface);
200 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), pbCurrentState);
204 static HRESULT WINAPI stillimagew_RefreshDeviceBus(IStillImageW *iface, LPCWSTR pwszDeviceName)
206 stillimage *This = impl_from_StillImageW(iface);
207 FIXME("(%p, %s): stub\n", This, debugstr_w(pwszDeviceName));
211 static HRESULT WINAPI stillimagew_LaunchApplicationForDevice(IStillImageW *iface, LPWSTR pwszDeviceName,
212 LPWSTR pwszAppName, LPSTINOTIFY pStiNotify)
214 stillimage *This = impl_from_StillImageW(iface);
215 FIXME("(%p, %s, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pwszAppName),
220 static HRESULT WINAPI stillimagew_SetupDeviceParameters(IStillImageW *iface, PSTI_DEVICE_INFORMATIONW pDevInfo)
222 stillimage *This = impl_from_StillImageW(iface);
223 FIXME("(%p, %p): stub\n", This, pDevInfo);
227 static HRESULT WINAPI stillimagew_WriteToErrorLog(IStillImageW *iface, DWORD dwMessageType, LPCWSTR pszMessage)
229 stillimage *This = impl_from_StillImageW(iface);
230 FIXME("(%p, %u, %s): stub\n", This, dwMessageType, debugstr_w(pszMessage));
234 static const struct IStillImageWVtbl stillimagew_vtbl =
236 stillimagew_QueryInterface,
239 stillimagew_Initialize,
240 stillimagew_GetDeviceList,
241 stillimagew_GetDeviceInfo,
242 stillimagew_CreateDevice,
243 stillimagew_GetDeviceValue,
244 stillimagew_SetDeviceValue,
245 stillimagew_GetSTILaunchInformation,
246 stillimagew_RegisterLaunchApplication,
247 stillimagew_UnregisterLaunchApplication,
248 stillimagew_EnableHwNotifications,
249 stillimagew_GetHwNotificationState,
250 stillimagew_RefreshDeviceBus,
251 stillimagew_LaunchApplicationForDevice,
252 stillimagew_SetupDeviceParameters,
253 stillimagew_WriteToErrorLog
256 static inline stillimage *impl_from_InternalUnknown(IUnknown *iface)
258 return (stillimage *)((char*)iface - FIELD_OFFSET(stillimage, lpInternalUnkVtbl));
261 static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
263 stillimage *This = impl_from_InternalUnknown(iface);
265 TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
267 if (IsEqualGUID(riid, &IID_IUnknown))
269 else if (IsEqualGUID(riid, &IID_IStillImageW))
270 *ppvObject = &This->lpVtbl;
273 if (IsEqualGUID(riid, &IID_IStillImageA))
274 FIXME("interface IStillImageA is unsupported on Windows Vista too, please report if it's needed\n");
276 FIXME("interface %s not implemented\n", debugstr_guid(riid));
278 return E_NOINTERFACE;
281 IUnknown_AddRef((IUnknown*) *ppvObject);
285 static ULONG WINAPI Internal_AddRef(IUnknown *iface)
287 stillimage *This = impl_from_InternalUnknown(iface);
288 return InterlockedIncrement(&This->ref);
291 static ULONG WINAPI Internal_Release(IUnknown *iface)
294 stillimage *This = impl_from_InternalUnknown(iface);
296 ref = InterlockedDecrement(&This->ref);
298 HeapFree(GetProcessHeap(), 0, This);
302 static const struct IUnknownVtbl internal_unk_vtbl =
304 Internal_QueryInterface,
309 /******************************************************************************
310 * StiCreateInstanceA (STI.@)
312 HRESULT WINAPI StiCreateInstanceA(HINSTANCE hinst, DWORD dwVer, PSTIA *ppSti, LPUNKNOWN pUnkOuter)
314 FIXME("(%p, %u, %p, %p): stub, unimplemented on Windows Vista too, please report if it's needed\n", hinst, dwVer, ppSti, pUnkOuter);
315 return STG_E_UNIMPLEMENTEDFUNCTION;
318 /******************************************************************************
319 * StiCreateInstanceW (STI.@)
321 HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LPUNKNOWN pUnkOuter)
326 TRACE("(%p, %u, %p, %p)\n", hinst, dwVer, ppSti, pUnkOuter);
328 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(stillimage));
331 This->lpVtbl = &stillimagew_vtbl;
332 This->lpInternalUnkVtbl = &internal_unk_vtbl;
334 This->pUnkOuter = pUnkOuter;
336 This->pUnkOuter = (IUnknown*) &This->lpInternalUnkVtbl;
339 hr = IStillImage_Initialize((IStillImageW*) &This->lpVtbl, hinst, dwVer);
343 *ppSti = (IStillImageW*) &This->lpInternalUnkVtbl;
345 *ppSti = (IStillImageW*) &This->lpVtbl;