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 "wine/debug.h"
32 #include "wine/unicode.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(sti);
36 static const WCHAR registeredAppsLaunchPath[] = {
37 'S','O','F','T','W','A','R','E','\\',
38 'M','i','c','r','o','s','o','f','t','\\',
39 'W','i','n','d','o','w','s','\\',
40 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
41 'S','t','i','l','l','I','m','a','g','e','\\',
42 'R','e','g','i','s','t','e','r','e','d',' ','A','p','p','l','i','c','a','t','i','o','n','s',0
45 typedef struct _stillimage
47 IStillImageW IStillImageW_iface;
48 IUnknown IUnknown_iface;
53 static inline stillimage *impl_from_IStillImageW(IStillImageW *iface)
55 return CONTAINING_RECORD(iface, stillimage, IStillImageW_iface);
58 static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID riid, void **ppvObject)
60 stillimage *This = impl_from_IStillImageW(iface);
61 TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
62 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
65 static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface)
67 stillimage *This = impl_from_IStillImageW(iface);
68 return IUnknown_AddRef(This->pUnkOuter);
71 static ULONG WINAPI stillimagew_Release(IStillImageW *iface)
73 stillimage *This = impl_from_IStillImageW(iface);
74 return IUnknown_Release(This->pUnkOuter);
77 static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hinst, DWORD dwVersion)
79 stillimage *This = impl_from_IStillImageW(iface);
80 TRACE("(%p, %p, 0x%X)\n", This, hinst, dwVersion);
84 static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwType, DWORD dwFlags,
85 DWORD *pdwItemsReturned, LPVOID *ppBuffer)
87 stillimage *This = impl_from_IStillImageW(iface);
88 FIXME("(%p, %u, 0x%X, %p, %p): stub\n", This, dwType, dwFlags, pdwItemsReturned, ppBuffer);
92 static HRESULT WINAPI stillimagew_GetDeviceInfo(IStillImageW *iface, LPWSTR pwszDeviceName,
95 stillimage *This = impl_from_IStillImageW(iface);
96 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), ppBuffer);
100 static HRESULT WINAPI stillimagew_CreateDevice(IStillImageW *iface, LPWSTR pwszDeviceName, DWORD dwMode,
101 PSTIDEVICEW *pDevice, LPUNKNOWN pUnkOuter)
103 stillimage *This = impl_from_IStillImageW(iface);
104 FIXME("(%p, %s, %u, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), dwMode, pDevice, pUnkOuter);
108 static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
109 LPDWORD pType, LPBYTE pData, LPDWORD cbData)
111 stillimage *This = impl_from_IStillImageW(iface);
112 FIXME("(%p, %s, %s, %p, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
113 pType, pData, cbData);
117 static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
118 DWORD type, LPBYTE pData, DWORD cbData)
120 stillimage *This = impl_from_IStillImageW(iface);
121 FIXME("(%p, %s, %s, %u, %p, %u): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
122 type, pData, cbData);
126 static HRESULT WINAPI stillimagew_GetSTILaunchInformation(IStillImageW *iface, LPWSTR pwszDeviceName,
127 DWORD *pdwEventCode, LPWSTR pwszEventName)
129 stillimage *This = impl_from_IStillImageW(iface);
130 FIXME("(%p, %p, %p, %p): stub\n", This, pwszDeviceName,
131 pdwEventCode, pwszEventName);
135 static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName,
136 LPWSTR pwszCommandLine)
138 static const WCHAR format[] = {'%','s',' ','%','s',0};
139 static const WCHAR commandLineSuffix[] = {
140 '/','S','t','i','D','e','v','i','c','e',':','%','1',' ',
141 '/','S','t','i','E','v','e','n','t',':','%','2',0};
142 HKEY registeredAppsKey = NULL;
145 stillimage *This = impl_from_IStillImageW(iface);
147 TRACE("(%p, %s, %s)\n", This, debugstr_w(pwszAppName), debugstr_w(pwszCommandLine));
149 ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, ®isteredAppsKey);
150 if (ret == ERROR_SUCCESS)
152 WCHAR *value = HeapAlloc(GetProcessHeap(), 0,
153 (lstrlenW(pwszCommandLine) + 1 + lstrlenW(commandLineSuffix) + 1) * sizeof(WCHAR));
156 sprintfW(value, format, pwszCommandLine, commandLineSuffix);
157 ret = RegSetValueExW(registeredAppsKey, pwszAppName, 0,
158 REG_SZ, (BYTE*)value, (lstrlenW(value)+1)*sizeof(WCHAR));
159 if (ret != ERROR_SUCCESS)
160 hr = HRESULT_FROM_WIN32(ret);
161 HeapFree(GetProcessHeap(), 0, value);
165 RegCloseKey(registeredAppsKey);
168 hr = HRESULT_FROM_WIN32(ret);
172 static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName)
174 stillimage *This = impl_from_IStillImageW(iface);
175 HKEY registeredAppsKey = NULL;
179 TRACE("(%p, %s)\n", This, debugstr_w(pwszAppName));
181 ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, ®isteredAppsKey);
182 if (ret == ERROR_SUCCESS)
184 ret = RegDeleteValueW(registeredAppsKey, pwszAppName);
185 if (ret != ERROR_SUCCESS)
186 hr = HRESULT_FROM_WIN32(ret);
187 RegCloseKey(registeredAppsKey);
190 hr = HRESULT_FROM_WIN32(ret);
194 static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPCWSTR pwszDeviceName,
197 stillimage *This = impl_from_IStillImageW(iface);
198 FIXME("(%p, %s, %u): stub\n", This, debugstr_w(pwszDeviceName), bNewState);
202 static HRESULT WINAPI stillimagew_GetHwNotificationState(IStillImageW *iface, LPCWSTR pwszDeviceName,
203 BOOL *pbCurrentState)
205 stillimage *This = impl_from_IStillImageW(iface);
206 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), pbCurrentState);
210 static HRESULT WINAPI stillimagew_RefreshDeviceBus(IStillImageW *iface, LPCWSTR pwszDeviceName)
212 stillimage *This = impl_from_IStillImageW(iface);
213 FIXME("(%p, %s): stub\n", This, debugstr_w(pwszDeviceName));
217 static HRESULT WINAPI stillimagew_LaunchApplicationForDevice(IStillImageW *iface, LPWSTR pwszDeviceName,
218 LPWSTR pwszAppName, LPSTINOTIFY pStiNotify)
220 stillimage *This = impl_from_IStillImageW(iface);
221 FIXME("(%p, %s, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pwszAppName),
226 static HRESULT WINAPI stillimagew_SetupDeviceParameters(IStillImageW *iface, PSTI_DEVICE_INFORMATIONW pDevInfo)
228 stillimage *This = impl_from_IStillImageW(iface);
229 FIXME("(%p, %p): stub\n", This, pDevInfo);
233 static HRESULT WINAPI stillimagew_WriteToErrorLog(IStillImageW *iface, DWORD dwMessageType, LPCWSTR pszMessage)
235 stillimage *This = impl_from_IStillImageW(iface);
236 FIXME("(%p, %u, %s): stub\n", This, dwMessageType, debugstr_w(pszMessage));
240 static const struct IStillImageWVtbl stillimagew_vtbl =
242 stillimagew_QueryInterface,
245 stillimagew_Initialize,
246 stillimagew_GetDeviceList,
247 stillimagew_GetDeviceInfo,
248 stillimagew_CreateDevice,
249 stillimagew_GetDeviceValue,
250 stillimagew_SetDeviceValue,
251 stillimagew_GetSTILaunchInformation,
252 stillimagew_RegisterLaunchApplication,
253 stillimagew_UnregisterLaunchApplication,
254 stillimagew_EnableHwNotifications,
255 stillimagew_GetHwNotificationState,
256 stillimagew_RefreshDeviceBus,
257 stillimagew_LaunchApplicationForDevice,
258 stillimagew_SetupDeviceParameters,
259 stillimagew_WriteToErrorLog
262 static inline stillimage *impl_from_IUnknown(IUnknown *iface)
264 return CONTAINING_RECORD(iface, stillimage, IUnknown_iface);
267 static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
269 stillimage *This = impl_from_IUnknown(iface);
271 TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
273 if (IsEqualGUID(riid, &IID_IUnknown))
275 else if (IsEqualGUID(riid, &IID_IStillImageW))
276 *ppvObject = &This->IStillImageW_iface;
279 if (IsEqualGUID(riid, &IID_IStillImageA))
280 FIXME("interface IStillImageA is unsupported on Windows Vista too, please report if it's needed\n");
282 FIXME("interface %s not implemented\n", debugstr_guid(riid));
284 return E_NOINTERFACE;
287 IUnknown_AddRef((IUnknown*) *ppvObject);
291 static ULONG WINAPI Internal_AddRef(IUnknown *iface)
293 stillimage *This = impl_from_IUnknown(iface);
294 return InterlockedIncrement(&This->ref);
297 static ULONG WINAPI Internal_Release(IUnknown *iface)
300 stillimage *This = impl_from_IUnknown(iface);
302 ref = InterlockedDecrement(&This->ref);
304 HeapFree(GetProcessHeap(), 0, This);
308 static const struct IUnknownVtbl internal_unk_vtbl =
310 Internal_QueryInterface,
315 /******************************************************************************
316 * StiCreateInstanceA (STI.@)
318 HRESULT WINAPI StiCreateInstanceA(HINSTANCE hinst, DWORD dwVer, PSTIA *ppSti, LPUNKNOWN pUnkOuter)
320 FIXME("(%p, %u, %p, %p): stub, unimplemented on Windows Vista too, please report if it's needed\n", hinst, dwVer, ppSti, pUnkOuter);
321 return STG_E_UNIMPLEMENTEDFUNCTION;
324 /******************************************************************************
325 * StiCreateInstanceW (STI.@)
327 HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LPUNKNOWN pUnkOuter)
332 TRACE("(%p, %u, %p, %p)\n", hinst, dwVer, ppSti, pUnkOuter);
334 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(stillimage));
337 This->IStillImageW_iface.lpVtbl = &stillimagew_vtbl;
338 This->IUnknown_iface.lpVtbl = &internal_unk_vtbl;
340 This->pUnkOuter = pUnkOuter;
342 This->pUnkOuter = &This->IUnknown_iface;
345 hr = IStillImage_Initialize(&This->IStillImageW_iface, hinst, dwVer);
349 *ppSti = (IStillImageW*) &This->IUnknown_iface;
351 *ppSti = &This->IStillImageW_iface;