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
20 #define WIN32_NO_STATUS
22 #define COM_NO_WINDOWS_H
31 //#include "winerror.h"
32 //#include "objbase.h"
35 #include <wine/debug.h>
36 #include <wine/unicode.h>
38 WINE_DEFAULT_DEBUG_CHANNEL(sti
);
40 static const WCHAR registeredAppsLaunchPath
[] = {
41 'S','O','F','T','W','A','R','E','\\',
42 'M','i','c','r','o','s','o','f','t','\\',
43 'W','i','n','d','o','w','s','\\',
44 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
45 'S','t','i','l','l','I','m','a','g','e','\\',
46 'R','e','g','i','s','t','e','r','e','d',' ','A','p','p','l','i','c','a','t','i','o','n','s',0
49 typedef struct _stillimage
51 IStillImageW IStillImageW_iface
;
52 IUnknown IUnknown_iface
;
57 static inline stillimage
*impl_from_IStillImageW(IStillImageW
*iface
)
59 return CONTAINING_RECORD(iface
, stillimage
, IStillImageW_iface
);
62 static HRESULT WINAPI
stillimagew_QueryInterface(IStillImageW
*iface
, REFIID riid
, void **ppvObject
)
64 stillimage
*This
= impl_from_IStillImageW(iface
);
65 TRACE("(%p %s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
66 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppvObject
);
69 static ULONG WINAPI
stillimagew_AddRef(IStillImageW
*iface
)
71 stillimage
*This
= impl_from_IStillImageW(iface
);
72 return IUnknown_AddRef(This
->pUnkOuter
);
75 static ULONG WINAPI
stillimagew_Release(IStillImageW
*iface
)
77 stillimage
*This
= impl_from_IStillImageW(iface
);
78 return IUnknown_Release(This
->pUnkOuter
);
81 static HRESULT WINAPI
stillimagew_Initialize(IStillImageW
*iface
, HINSTANCE hinst
, DWORD dwVersion
)
83 stillimage
*This
= impl_from_IStillImageW(iface
);
84 TRACE("(%p, %p, 0x%X)\n", This
, hinst
, dwVersion
);
88 static HRESULT WINAPI
stillimagew_GetDeviceList(IStillImageW
*iface
, DWORD dwType
, DWORD dwFlags
,
89 DWORD
*pdwItemsReturned
, LPVOID
*ppBuffer
)
91 stillimage
*This
= impl_from_IStillImageW(iface
);
92 FIXME("(%p, %u, 0x%X, %p, %p): stub\n", This
, dwType
, dwFlags
, pdwItemsReturned
, ppBuffer
);
96 static HRESULT WINAPI
stillimagew_GetDeviceInfo(IStillImageW
*iface
, LPWSTR pwszDeviceName
,
99 stillimage
*This
= impl_from_IStillImageW(iface
);
100 FIXME("(%p, %s, %p): stub\n", This
, debugstr_w(pwszDeviceName
), ppBuffer
);
104 static HRESULT WINAPI
stillimagew_CreateDevice(IStillImageW
*iface
, LPWSTR pwszDeviceName
, DWORD dwMode
,
105 PSTIDEVICEW
*pDevice
, LPUNKNOWN pUnkOuter
)
107 stillimage
*This
= impl_from_IStillImageW(iface
);
108 FIXME("(%p, %s, %u, %p, %p): stub\n", This
, debugstr_w(pwszDeviceName
), dwMode
, pDevice
, pUnkOuter
);
112 static HRESULT WINAPI
stillimagew_GetDeviceValue(IStillImageW
*iface
, LPWSTR pwszDeviceName
, LPWSTR pValueName
,
113 LPDWORD pType
, LPBYTE pData
, LPDWORD cbData
)
115 stillimage
*This
= impl_from_IStillImageW(iface
);
116 FIXME("(%p, %s, %s, %p, %p, %p): stub\n", This
, debugstr_w(pwszDeviceName
), debugstr_w(pValueName
),
117 pType
, pData
, cbData
);
121 static HRESULT WINAPI
stillimagew_SetDeviceValue(IStillImageW
*iface
, LPWSTR pwszDeviceName
, LPWSTR pValueName
,
122 DWORD type
, LPBYTE pData
, DWORD cbData
)
124 stillimage
*This
= impl_from_IStillImageW(iface
);
125 FIXME("(%p, %s, %s, %u, %p, %u): stub\n", This
, debugstr_w(pwszDeviceName
), debugstr_w(pValueName
),
126 type
, pData
, cbData
);
130 static HRESULT WINAPI
stillimagew_GetSTILaunchInformation(IStillImageW
*iface
, LPWSTR pwszDeviceName
,
131 DWORD
*pdwEventCode
, LPWSTR pwszEventName
)
133 stillimage
*This
= impl_from_IStillImageW(iface
);
134 FIXME("(%p, %p, %p, %p): stub\n", This
, pwszDeviceName
,
135 pdwEventCode
, pwszEventName
);
139 static HRESULT WINAPI
stillimagew_RegisterLaunchApplication(IStillImageW
*iface
, LPWSTR pwszAppName
,
140 LPWSTR pwszCommandLine
)
142 static const WCHAR format
[] = {'%','s',' ','%','s',0};
143 static const WCHAR commandLineSuffix
[] = {
144 '/','S','t','i','D','e','v','i','c','e',':','%','1',' ',
145 '/','S','t','i','E','v','e','n','t',':','%','2',0};
146 HKEY registeredAppsKey
= NULL
;
149 stillimage
*This
= impl_from_IStillImageW(iface
);
151 TRACE("(%p, %s, %s)\n", This
, debugstr_w(pwszAppName
), debugstr_w(pwszCommandLine
));
153 ret
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, registeredAppsLaunchPath
, ®isteredAppsKey
);
154 if (ret
== ERROR_SUCCESS
)
156 WCHAR
*value
= HeapAlloc(GetProcessHeap(), 0,
157 (lstrlenW(pwszCommandLine
) + 1 + lstrlenW(commandLineSuffix
) + 1) * sizeof(WCHAR
));
160 sprintfW(value
, format
, pwszCommandLine
, commandLineSuffix
);
161 ret
= RegSetValueExW(registeredAppsKey
, pwszAppName
, 0,
162 REG_SZ
, (BYTE
*)value
, (lstrlenW(value
)+1)*sizeof(WCHAR
));
163 if (ret
!= ERROR_SUCCESS
)
164 hr
= HRESULT_FROM_WIN32(ret
);
165 HeapFree(GetProcessHeap(), 0, value
);
169 RegCloseKey(registeredAppsKey
);
172 hr
= HRESULT_FROM_WIN32(ret
);
176 static HRESULT WINAPI
stillimagew_UnregisterLaunchApplication(IStillImageW
*iface
, LPWSTR pwszAppName
)
178 stillimage
*This
= impl_from_IStillImageW(iface
);
179 HKEY registeredAppsKey
= NULL
;
183 TRACE("(%p, %s)\n", This
, debugstr_w(pwszAppName
));
185 ret
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, registeredAppsLaunchPath
, ®isteredAppsKey
);
186 if (ret
== ERROR_SUCCESS
)
188 ret
= RegDeleteValueW(registeredAppsKey
, pwszAppName
);
189 if (ret
!= ERROR_SUCCESS
)
190 hr
= HRESULT_FROM_WIN32(ret
);
191 RegCloseKey(registeredAppsKey
);
194 hr
= HRESULT_FROM_WIN32(ret
);
198 static HRESULT WINAPI
stillimagew_EnableHwNotifications(IStillImageW
*iface
, LPCWSTR pwszDeviceName
,
201 stillimage
*This
= impl_from_IStillImageW(iface
);
202 FIXME("(%p, %s, %u): stub\n", This
, debugstr_w(pwszDeviceName
), bNewState
);
206 static HRESULT WINAPI
stillimagew_GetHwNotificationState(IStillImageW
*iface
, LPCWSTR pwszDeviceName
,
207 BOOL
*pbCurrentState
)
209 stillimage
*This
= impl_from_IStillImageW(iface
);
210 FIXME("(%p, %s, %p): stub\n", This
, debugstr_w(pwszDeviceName
), pbCurrentState
);
214 static HRESULT WINAPI
stillimagew_RefreshDeviceBus(IStillImageW
*iface
, LPCWSTR pwszDeviceName
)
216 stillimage
*This
= impl_from_IStillImageW(iface
);
217 FIXME("(%p, %s): stub\n", This
, debugstr_w(pwszDeviceName
));
221 static HRESULT WINAPI
stillimagew_LaunchApplicationForDevice(IStillImageW
*iface
, LPWSTR pwszDeviceName
,
222 LPWSTR pwszAppName
, LPSTINOTIFY pStiNotify
)
224 stillimage
*This
= impl_from_IStillImageW(iface
);
225 FIXME("(%p, %s, %s, %p): stub\n", This
, debugstr_w(pwszDeviceName
), debugstr_w(pwszAppName
),
230 static HRESULT WINAPI
stillimagew_SetupDeviceParameters(IStillImageW
*iface
, PSTI_DEVICE_INFORMATIONW pDevInfo
)
232 stillimage
*This
= impl_from_IStillImageW(iface
);
233 FIXME("(%p, %p): stub\n", This
, pDevInfo
);
237 static HRESULT WINAPI
stillimagew_WriteToErrorLog(IStillImageW
*iface
, DWORD dwMessageType
, LPCWSTR pszMessage
)
239 stillimage
*This
= impl_from_IStillImageW(iface
);
240 FIXME("(%p, %u, %s): stub\n", This
, dwMessageType
, debugstr_w(pszMessage
));
244 static const struct IStillImageWVtbl stillimagew_vtbl
=
246 stillimagew_QueryInterface
,
249 stillimagew_Initialize
,
250 stillimagew_GetDeviceList
,
251 stillimagew_GetDeviceInfo
,
252 stillimagew_CreateDevice
,
253 stillimagew_GetDeviceValue
,
254 stillimagew_SetDeviceValue
,
255 stillimagew_GetSTILaunchInformation
,
256 stillimagew_RegisterLaunchApplication
,
257 stillimagew_UnregisterLaunchApplication
,
258 stillimagew_EnableHwNotifications
,
259 stillimagew_GetHwNotificationState
,
260 stillimagew_RefreshDeviceBus
,
261 stillimagew_LaunchApplicationForDevice
,
262 stillimagew_SetupDeviceParameters
,
263 stillimagew_WriteToErrorLog
266 static inline stillimage
*impl_from_IUnknown(IUnknown
*iface
)
268 return CONTAINING_RECORD(iface
, stillimage
, IUnknown_iface
);
271 static HRESULT WINAPI
Internal_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppvObject
)
273 stillimage
*This
= impl_from_IUnknown(iface
);
275 TRACE("(%p %s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
277 if (IsEqualGUID(riid
, &IID_IUnknown
))
279 else if (IsEqualGUID(riid
, &IID_IStillImageW
))
280 *ppvObject
= &This
->IStillImageW_iface
;
283 if (IsEqualGUID(riid
, &IID_IStillImageA
))
284 FIXME("interface IStillImageA is unsupported on Windows Vista too, please report if it's needed\n");
286 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
288 return E_NOINTERFACE
;
291 IUnknown_AddRef((IUnknown
*) *ppvObject
);
295 static ULONG WINAPI
Internal_AddRef(IUnknown
*iface
)
297 stillimage
*This
= impl_from_IUnknown(iface
);
298 return InterlockedIncrement(&This
->ref
);
301 static ULONG WINAPI
Internal_Release(IUnknown
*iface
)
304 stillimage
*This
= impl_from_IUnknown(iface
);
306 ref
= InterlockedDecrement(&This
->ref
);
308 HeapFree(GetProcessHeap(), 0, This
);
312 static const struct IUnknownVtbl internal_unk_vtbl
=
314 Internal_QueryInterface
,
319 /******************************************************************************
320 * StiCreateInstanceA (STI.@)
322 HRESULT WINAPI
StiCreateInstanceA(HINSTANCE hinst
, DWORD dwVer
, PSTIA
*ppSti
, LPUNKNOWN pUnkOuter
)
324 FIXME("(%p, %u, %p, %p): stub, unimplemented on Windows Vista too, please report if it's needed\n", hinst
, dwVer
, ppSti
, pUnkOuter
);
325 return STG_E_UNIMPLEMENTEDFUNCTION
;
328 /******************************************************************************
329 * StiCreateInstanceW (STI.@)
331 HRESULT WINAPI
StiCreateInstanceW(HINSTANCE hinst
, DWORD dwVer
, PSTIW
*ppSti
, LPUNKNOWN pUnkOuter
)
336 TRACE("(%p, %u, %p, %p)\n", hinst
, dwVer
, ppSti
, pUnkOuter
);
338 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(stillimage
));
341 This
->IStillImageW_iface
.lpVtbl
= &stillimagew_vtbl
;
342 This
->IUnknown_iface
.lpVtbl
= &internal_unk_vtbl
;
344 This
->pUnkOuter
= pUnkOuter
;
346 This
->pUnkOuter
= &This
->IUnknown_iface
;
349 hr
= IStillImage_Initialize(&This
->IStillImageW_iface
, hinst
, dwVer
);
353 *ppSti
= (IStillImageW
*) &This
->IUnknown_iface
;
355 *ppSti
= &This
->IStillImageW_iface
;