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"
33 WINE_DEFAULT_DEBUG_CHANNEL(sti
);
35 static const WCHAR registeredAppsLaunchPath
[] =
36 L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\StillImage\\Registered Applications";
38 typedef struct _stillimage
40 IUnknown IUnknown_inner
;
41 IStillImageW IStillImageW_iface
;
46 static inline stillimage
*impl_from_IStillImageW(IStillImageW
*iface
)
48 return CONTAINING_RECORD(iface
, stillimage
, IStillImageW_iface
);
51 static HRESULT WINAPI
stillimagew_QueryInterface(IStillImageW
*iface
, REFIID riid
, void **ppvObject
)
53 stillimage
*This
= impl_from_IStillImageW(iface
);
54 TRACE("(%p %s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
55 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObject
);
58 static ULONG WINAPI
stillimagew_AddRef(IStillImageW
*iface
)
60 stillimage
*This
= impl_from_IStillImageW(iface
);
61 return IUnknown_AddRef(This
->outer_unk
);
64 static ULONG WINAPI
stillimagew_Release(IStillImageW
*iface
)
66 stillimage
*This
= impl_from_IStillImageW(iface
);
67 return IUnknown_Release(This
->outer_unk
);
70 static HRESULT WINAPI
stillimagew_Initialize(IStillImageW
*iface
, HINSTANCE hinst
, DWORD dwVersion
)
72 stillimage
*This
= impl_from_IStillImageW(iface
);
73 TRACE("(%p, %p, 0x%X)\n", This
, hinst
, dwVersion
);
77 static HRESULT WINAPI
stillimagew_GetDeviceList(IStillImageW
*iface
, DWORD dwType
, DWORD dwFlags
,
78 DWORD
*pdwItemsReturned
, LPVOID
*ppBuffer
)
80 stillimage
*This
= impl_from_IStillImageW(iface
);
81 FIXME("(%p, %u, 0x%X, %p, %p): stub\n", This
, dwType
, dwFlags
, pdwItemsReturned
, ppBuffer
);
85 static HRESULT WINAPI
stillimagew_GetDeviceInfo(IStillImageW
*iface
, LPWSTR pwszDeviceName
,
88 stillimage
*This
= impl_from_IStillImageW(iface
);
89 FIXME("(%p, %s, %p): stub\n", This
, debugstr_w(pwszDeviceName
), ppBuffer
);
93 static HRESULT WINAPI
stillimagew_CreateDevice(IStillImageW
*iface
, LPWSTR pwszDeviceName
, DWORD dwMode
,
94 PSTIDEVICEW
*pDevice
, LPUNKNOWN pUnkOuter
)
96 stillimage
*This
= impl_from_IStillImageW(iface
);
97 FIXME("(%p, %s, %u, %p, %p): stub\n", This
, debugstr_w(pwszDeviceName
), dwMode
, pDevice
, pUnkOuter
);
101 static HRESULT WINAPI
stillimagew_GetDeviceValue(IStillImageW
*iface
, LPWSTR pwszDeviceName
, LPWSTR pValueName
,
102 LPDWORD pType
, LPBYTE pData
, LPDWORD cbData
)
104 stillimage
*This
= impl_from_IStillImageW(iface
);
105 FIXME("(%p, %s, %s, %p, %p, %p): stub\n", This
, debugstr_w(pwszDeviceName
), debugstr_w(pValueName
),
106 pType
, pData
, cbData
);
110 static HRESULT WINAPI
stillimagew_SetDeviceValue(IStillImageW
*iface
, LPWSTR pwszDeviceName
, LPWSTR pValueName
,
111 DWORD type
, LPBYTE pData
, DWORD cbData
)
113 stillimage
*This
= impl_from_IStillImageW(iface
);
114 FIXME("(%p, %s, %s, %u, %p, %u): stub\n", This
, debugstr_w(pwszDeviceName
), debugstr_w(pValueName
),
115 type
, pData
, cbData
);
119 static HRESULT WINAPI
stillimagew_GetSTILaunchInformation(IStillImageW
*iface
, LPWSTR pwszDeviceName
,
120 DWORD
*pdwEventCode
, LPWSTR pwszEventName
)
122 stillimage
*This
= impl_from_IStillImageW(iface
);
123 FIXME("(%p, %p, %p, %p): stub\n", This
, pwszDeviceName
,
124 pdwEventCode
, pwszEventName
);
128 static HRESULT WINAPI
stillimagew_RegisterLaunchApplication(IStillImageW
*iface
, LPWSTR pwszAppName
,
129 LPWSTR pwszCommandLine
)
131 static const WCHAR commandLineSuffix
[] = L
"/StiDevice:%1 /StiEvent:%2";
132 HKEY registeredAppsKey
= NULL
;
135 stillimage
*This
= impl_from_IStillImageW(iface
);
137 TRACE("(%p, %s, %s)\n", This
, debugstr_w(pwszAppName
), debugstr_w(pwszCommandLine
));
139 ret
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, registeredAppsLaunchPath
, ®isteredAppsKey
);
140 if (ret
== ERROR_SUCCESS
)
142 size_t len
= lstrlenW(pwszCommandLine
) + 1 + lstrlenW(commandLineSuffix
) + 1;
143 WCHAR
*value
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
146 swprintf(value
, len
, L
"%s %s", pwszCommandLine
, commandLineSuffix
);
147 ret
= RegSetValueExW(registeredAppsKey
, pwszAppName
, 0,
148 REG_SZ
, (BYTE
*)value
, (lstrlenW(value
)+1)*sizeof(WCHAR
));
149 if (ret
!= ERROR_SUCCESS
)
150 hr
= HRESULT_FROM_WIN32(ret
);
151 HeapFree(GetProcessHeap(), 0, value
);
155 RegCloseKey(registeredAppsKey
);
158 hr
= HRESULT_FROM_WIN32(ret
);
162 static HRESULT WINAPI
stillimagew_UnregisterLaunchApplication(IStillImageW
*iface
, LPWSTR pwszAppName
)
164 stillimage
*This
= impl_from_IStillImageW(iface
);
165 HKEY registeredAppsKey
= NULL
;
169 TRACE("(%p, %s)\n", This
, debugstr_w(pwszAppName
));
171 ret
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, registeredAppsLaunchPath
, ®isteredAppsKey
);
172 if (ret
== ERROR_SUCCESS
)
174 ret
= RegDeleteValueW(registeredAppsKey
, pwszAppName
);
175 if (ret
!= ERROR_SUCCESS
)
176 hr
= HRESULT_FROM_WIN32(ret
);
177 RegCloseKey(registeredAppsKey
);
180 hr
= HRESULT_FROM_WIN32(ret
);
184 static HRESULT WINAPI
stillimagew_EnableHwNotifications(IStillImageW
*iface
, LPCWSTR pwszDeviceName
,
187 stillimage
*This
= impl_from_IStillImageW(iface
);
188 FIXME("(%p, %s, %u): stub\n", This
, debugstr_w(pwszDeviceName
), bNewState
);
192 static HRESULT WINAPI
stillimagew_GetHwNotificationState(IStillImageW
*iface
, LPCWSTR pwszDeviceName
,
193 BOOL
*pbCurrentState
)
195 stillimage
*This
= impl_from_IStillImageW(iface
);
196 FIXME("(%p, %s, %p): stub\n", This
, debugstr_w(pwszDeviceName
), pbCurrentState
);
200 static HRESULT WINAPI
stillimagew_RefreshDeviceBus(IStillImageW
*iface
, LPCWSTR pwszDeviceName
)
202 stillimage
*This
= impl_from_IStillImageW(iface
);
203 FIXME("(%p, %s): stub\n", This
, debugstr_w(pwszDeviceName
));
207 static HRESULT WINAPI
stillimagew_LaunchApplicationForDevice(IStillImageW
*iface
, LPWSTR pwszDeviceName
,
208 LPWSTR pwszAppName
, LPSTINOTIFY pStiNotify
)
210 stillimage
*This
= impl_from_IStillImageW(iface
);
211 FIXME("(%p, %s, %s, %p): stub\n", This
, debugstr_w(pwszDeviceName
), debugstr_w(pwszAppName
),
216 static HRESULT WINAPI
stillimagew_SetupDeviceParameters(IStillImageW
*iface
, PSTI_DEVICE_INFORMATIONW pDevInfo
)
218 stillimage
*This
= impl_from_IStillImageW(iface
);
219 FIXME("(%p, %p): stub\n", This
, pDevInfo
);
223 static HRESULT WINAPI
stillimagew_WriteToErrorLog(IStillImageW
*iface
, DWORD dwMessageType
, LPCWSTR pszMessage
)
225 stillimage
*This
= impl_from_IStillImageW(iface
);
226 FIXME("(%p, %u, %s): stub\n", This
, dwMessageType
, debugstr_w(pszMessage
));
230 static const struct IStillImageWVtbl stillimagew_vtbl
=
232 stillimagew_QueryInterface
,
235 stillimagew_Initialize
,
236 stillimagew_GetDeviceList
,
237 stillimagew_GetDeviceInfo
,
238 stillimagew_CreateDevice
,
239 stillimagew_GetDeviceValue
,
240 stillimagew_SetDeviceValue
,
241 stillimagew_GetSTILaunchInformation
,
242 stillimagew_RegisterLaunchApplication
,
243 stillimagew_UnregisterLaunchApplication
,
244 stillimagew_EnableHwNotifications
,
245 stillimagew_GetHwNotificationState
,
246 stillimagew_RefreshDeviceBus
,
247 stillimagew_LaunchApplicationForDevice
,
248 stillimagew_SetupDeviceParameters
,
249 stillimagew_WriteToErrorLog
252 static inline stillimage
*impl_from_IUnknown(IUnknown
*iface
)
254 return CONTAINING_RECORD(iface
, stillimage
, IUnknown_inner
);
257 static HRESULT WINAPI
Internal_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppvObject
)
259 stillimage
*This
= impl_from_IUnknown(iface
);
261 TRACE("(%p %s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
263 if (IsEqualGUID(riid
, &IID_IUnknown
))
265 else if (IsEqualGUID(riid
, &IID_IStillImageW
))
266 *ppvObject
= &This
->IStillImageW_iface
;
269 if (IsEqualGUID(riid
, &IID_IStillImageA
))
270 FIXME("interface IStillImageA is unsupported on Windows Vista too, please report if it's needed\n");
272 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
274 return E_NOINTERFACE
;
277 IUnknown_AddRef((IUnknown
*) *ppvObject
);
281 static ULONG WINAPI
Internal_AddRef(IUnknown
*iface
)
283 stillimage
*This
= impl_from_IUnknown(iface
);
284 return InterlockedIncrement(&This
->ref
);
287 static ULONG WINAPI
Internal_Release(IUnknown
*iface
)
290 stillimage
*This
= impl_from_IUnknown(iface
);
292 ref
= InterlockedDecrement(&This
->ref
);
294 HeapFree(GetProcessHeap(), 0, This
);
298 static const struct IUnknownVtbl internal_unk_vtbl
=
300 Internal_QueryInterface
,
305 /******************************************************************************
306 * StiCreateInstanceA (STI.@)
308 HRESULT WINAPI
StiCreateInstanceA(HINSTANCE hinst
, DWORD dwVer
, PSTIA
*ppSti
, LPUNKNOWN pUnkOuter
)
310 FIXME("(%p, %u, %p, %p): stub, unimplemented on Windows Vista too, please report if it's needed\n", hinst
, dwVer
, ppSti
, pUnkOuter
);
311 return STG_E_UNIMPLEMENTEDFUNCTION
;
314 /******************************************************************************
315 * StiCreateInstanceW (STI.@)
317 HRESULT WINAPI
StiCreateInstanceW(HINSTANCE hinst
, DWORD dwVer
, PSTIW
*ppSti
, LPUNKNOWN pUnkOuter
)
322 TRACE("(%p, %u, %p, %p)\n", hinst
, dwVer
, ppSti
, pUnkOuter
);
324 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(stillimage
));
327 This
->IStillImageW_iface
.lpVtbl
= &stillimagew_vtbl
;
328 This
->IUnknown_inner
.lpVtbl
= &internal_unk_vtbl
;
330 This
->outer_unk
= pUnkOuter
;
332 This
->outer_unk
= &This
->IUnknown_inner
;
335 hr
= IStillImage_Initialize(&This
->IStillImageW_iface
, hinst
, dwVer
);
339 *ppSti
= (IStillImageW
*) &This
->IUnknown_inner
;
341 *ppSti
= &This
->IStillImageW_iface
;