ReactOS 0.4.15-dev-8348-gc1b9bb5
sti.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002 Aric Stewart for CodeWeavers
3 * Copyright (C) 2009 Damjan Jovanovic
4 *
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.
9 *
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.
14 *
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
18 */
19
20#include <stdarg.h>
21#ifdef __REACTOS__
22#include <wchar.h>
23#endif
24
25#define COBJMACROS
26
27#include "windef.h"
28#include "winbase.h"
29#include "winreg.h"
30#include "winerror.h"
31#include "objbase.h"
32#include "sti.h"
33
34#include "wine/debug.h"
35
37
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
45};
46
47typedef struct _stillimage
48{
50 IStillImageW IStillImageW_iface;
54
55static inline stillimage *impl_from_IStillImageW(IStillImageW *iface)
56{
57 return CONTAINING_RECORD(iface, stillimage, IStillImageW_iface);
58}
59
60static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID riid, void **ppvObject)
61{
63 TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
64 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObject);
65}
66
67static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface)
68{
70 return IUnknown_AddRef(This->outer_unk);
71}
72
73static ULONG WINAPI stillimagew_Release(IStillImageW *iface)
74{
76 return IUnknown_Release(This->outer_unk);
77}
78
79static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hinst, DWORD dwVersion)
80{
82 TRACE("(%p, %p, 0x%X)\n", This, hinst, dwVersion);
83 return S_OK;
84}
85
86static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwType, DWORD dwFlags,
87 DWORD *pdwItemsReturned, LPVOID *ppBuffer)
88{
90 FIXME("(%p, %u, 0x%X, %p, %p): stub\n", This, dwType, dwFlags, pdwItemsReturned, ppBuffer);
91 return E_NOTIMPL;
92}
93
95 LPVOID *ppBuffer)
96{
98 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), ppBuffer);
99 return E_NOTIMPL;
100}
101
103 PSTIDEVICEW *pDevice, LPUNKNOWN pUnkOuter)
104{
106 FIXME("(%p, %s, %u, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), dwMode, pDevice, pUnkOuter);
107 return E_NOTIMPL;
108}
109
110static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
111 LPDWORD pType, LPBYTE pData, LPDWORD cbData)
112{
114 FIXME("(%p, %s, %s, %p, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
115 pType, pData, cbData);
116 return E_NOTIMPL;
117}
118
119static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
120 DWORD type, LPBYTE pData, DWORD cbData)
121{
123 FIXME("(%p, %s, %s, %u, %p, %u): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
124 type, pData, cbData);
125 return E_NOTIMPL;
126}
127
129 DWORD *pdwEventCode, LPWSTR pwszEventName)
130{
132 FIXME("(%p, %p, %p, %p): stub\n", This, pwszDeviceName,
133 pdwEventCode, pwszEventName);
134 return E_NOTIMPL;
135}
136
137static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName,
138 LPWSTR pwszCommandLine)
139{
140 static const WCHAR format[] = {'%','s',' ','%','s',0};
141 static const WCHAR commandLineSuffix[] = {
142 '/','S','t','i','D','e','v','i','c','e',':','%','1',' ',
143 '/','S','t','i','E','v','e','n','t',':','%','2',0};
144 HKEY registeredAppsKey = NULL;
145 DWORD ret;
146 HRESULT hr = S_OK;
148
149 TRACE("(%p, %s, %s)\n", This, debugstr_w(pwszAppName), debugstr_w(pwszCommandLine));
150
152 if (ret == ERROR_SUCCESS)
153 {
154 size_t len = lstrlenW(pwszCommandLine) + 1 + lstrlenW(commandLineSuffix) + 1;
155 WCHAR *value = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
156 if (value)
157 {
158 swprintf(value, format, pwszCommandLine, commandLineSuffix);
159 ret = RegSetValueExW(registeredAppsKey, pwszAppName, 0,
160 REG_SZ, (BYTE*)value, (lstrlenW(value)+1)*sizeof(WCHAR));
161 if (ret != ERROR_SUCCESS)
164 }
165 else
167 RegCloseKey(registeredAppsKey);
168 }
169 else
171 return hr;
172}
173
174static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName)
175{
177 HKEY registeredAppsKey = NULL;
178 DWORD ret;
179 HRESULT hr = S_OK;
180
181 TRACE("(%p, %s)\n", This, debugstr_w(pwszAppName));
182
184 if (ret == ERROR_SUCCESS)
185 {
186 ret = RegDeleteValueW(registeredAppsKey, pwszAppName);
187 if (ret != ERROR_SUCCESS)
189 RegCloseKey(registeredAppsKey);
190 }
191 else
193 return hr;
194}
195
197 BOOL bNewState)
198{
200 FIXME("(%p, %s, %u): stub\n", This, debugstr_w(pwszDeviceName), bNewState);
201 return E_NOTIMPL;
202}
203
205 BOOL *pbCurrentState)
206{
208 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), pbCurrentState);
209 return E_NOTIMPL;
210}
211
213{
215 FIXME("(%p, %s): stub\n", This, debugstr_w(pwszDeviceName));
216 return E_NOTIMPL;
217}
218
220 LPWSTR pwszAppName, LPSTINOTIFY pStiNotify)
221{
223 FIXME("(%p, %s, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pwszAppName),
224 pStiNotify);
225 return E_NOTIMPL;
226}
227
229{
231 FIXME("(%p, %p): stub\n", This, pDevInfo);
232 return E_NOTIMPL;
233}
234
235static HRESULT WINAPI stillimagew_WriteToErrorLog(IStillImageW *iface, DWORD dwMessageType, LPCWSTR pszMessage)
236{
238 FIXME("(%p, %u, %s): stub\n", This, dwMessageType, debugstr_w(pszMessage));
239 return E_NOTIMPL;
240}
241
242static const struct IStillImageWVtbl stillimagew_vtbl =
243{
262};
263
265{
266 return CONTAINING_RECORD(iface, stillimage, IUnknown_inner);
267}
268
270{
272
273 TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
274
276 *ppvObject = iface;
277 else if (IsEqualGUID(riid, &IID_IStillImageW))
278 *ppvObject = &This->IStillImageW_iface;
279 else
280 {
281 if (IsEqualGUID(riid, &IID_IStillImageA))
282 FIXME("interface IStillImageA is unsupported on Windows Vista too, please report if it's needed\n");
283 else
284 FIXME("interface %s not implemented\n", debugstr_guid(riid));
285 *ppvObject = NULL;
286 return E_NOINTERFACE;
287 }
288
289 IUnknown_AddRef((IUnknown*) *ppvObject);
290 return S_OK;
291}
292
294{
296 return InterlockedIncrement(&This->ref);
297}
298
300{
301 ULONG ref;
303
305 if (ref == 0)
307 return ref;
308}
309
310static const struct IUnknownVtbl internal_unk_vtbl =
311{
315};
316
317/******************************************************************************
318 * StiCreateInstanceA (STI.@)
319 */
321{
322 FIXME("(%p, %u, %p, %p): stub, unimplemented on Windows Vista too, please report if it's needed\n", hinst, dwVer, ppSti, pUnkOuter);
324}
325
326/******************************************************************************
327 * StiCreateInstanceW (STI.@)
328 */
330{
332 HRESULT hr;
333
334 TRACE("(%p, %u, %p, %p)\n", hinst, dwVer, ppSti, pUnkOuter);
335
337 if (This)
338 {
339 This->IStillImageW_iface.lpVtbl = &stillimagew_vtbl;
340 This->IUnknown_inner.lpVtbl = &internal_unk_vtbl;
341 if (pUnkOuter)
342 This->outer_unk = pUnkOuter;
343 else
344 This->outer_unk = &This->IUnknown_inner;
345 This->ref = 1;
346
347 hr = IStillImage_Initialize(&This->IStillImageW_iface, hinst, dwVer);
348 if (SUCCEEDED(hr))
349 {
350 if (pUnkOuter)
351 *ppSti = (IStillImageW*) &This->IUnknown_inner;
352 else
353 *ppSti = &This->IStillImageW_iface;
354 }
355 }
356 else
358
359 return hr;
360}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
const GUID IID_IUnknown
#define RegCloseKey(hKey)
Definition: registry.h:49
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define lstrlenW
Definition: compat.h:750
static HRESULT WINAPI stillimagew_GetSTILaunchInformation(IStillImageW *iface, LPWSTR pwszDeviceName, DWORD *pdwEventCode, LPWSTR pwszEventName)
Definition: sti.c:128
static HRESULT WINAPI stillimagew_GetHwNotificationState(IStillImageW *iface, LPCWSTR pwszDeviceName, BOOL *pbCurrentState)
Definition: sti.c:204
static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface)
Definition: sti.c:67
static ULONG WINAPI Internal_AddRef(IUnknown *iface)
Definition: sti.c:293
static HRESULT WINAPI stillimagew_RefreshDeviceBus(IStillImageW *iface, LPCWSTR pwszDeviceName)
Definition: sti.c:212
HRESULT WINAPI StiCreateInstanceA(HINSTANCE hinst, DWORD dwVer, PSTIA *ppSti, LPUNKNOWN pUnkOuter)
Definition: sti.c:320
HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LPUNKNOWN pUnkOuter)
Definition: sti.c:329
static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
Definition: sti.c:269
static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName)
Definition: sti.c:174
static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName, LPWSTR pwszCommandLine)
Definition: sti.c:137
static const struct IStillImageWVtbl stillimagew_vtbl
Definition: sti.c:242
static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwType, DWORD dwFlags, DWORD *pdwItemsReturned, LPVOID *ppBuffer)
Definition: sti.c:86
static const WCHAR registeredAppsLaunchPath[]
Definition: sti.c:38
static stillimage * impl_from_IStillImageW(IStillImageW *iface)
Definition: sti.c:55
static HRESULT WINAPI stillimagew_CreateDevice(IStillImageW *iface, LPWSTR pwszDeviceName, DWORD dwMode, PSTIDEVICEW *pDevice, LPUNKNOWN pUnkOuter)
Definition: sti.c:102
static HRESULT WINAPI stillimagew_LaunchApplicationForDevice(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pwszAppName, LPSTINOTIFY pStiNotify)
Definition: sti.c:219
struct _stillimage stillimage
static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID riid, void **ppvObject)
Definition: sti.c:60
static ULONG WINAPI stillimagew_Release(IStillImageW *iface)
Definition: sti.c:73
static HRESULT WINAPI stillimagew_SetupDeviceParameters(IStillImageW *iface, PSTI_DEVICE_INFORMATIONW pDevInfo)
Definition: sti.c:228
static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hinst, DWORD dwVersion)
Definition: sti.c:79
static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName, DWORD type, LPBYTE pData, DWORD cbData)
Definition: sti.c:119
static HRESULT WINAPI stillimagew_WriteToErrorLog(IStillImageW *iface, DWORD dwMessageType, LPCWSTR pszMessage)
Definition: sti.c:235
static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPCWSTR pwszDeviceName, BOOL bNewState)
Definition: sti.c:196
static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName, LPDWORD pType, LPBYTE pData, LPDWORD cbData)
Definition: sti.c:110
static ULONG WINAPI Internal_Release(IUnknown *iface)
Definition: sti.c:299
static HRESULT WINAPI stillimagew_GetDeviceInfo(IStillImageW *iface, LPWSTR pwszDeviceName, LPVOID *ppBuffer)
Definition: sti.c:94
static stillimage * impl_from_IUnknown(IUnknown *iface)
Definition: sti.c:264
static const struct IUnknownVtbl internal_unk_vtbl
Definition: sti.c:310
#define swprintf
Definition: precomp.h:40
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxDevice * pDevice
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLenum GLsizei len
Definition: glext.h:6722
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
#define REG_SZ
Definition: layer.c:22
static HINSTANCE hinst
Definition: edit.c:551
static LPUNKNOWN
Definition: ndr_ole.c:49
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
struct IStiDeviceW * PSTIDEVICEW
Definition: sti.h:56
struct IStillImageW * PSTIW
Definition: sti.h:50
struct IStillImageA * PSTIA
Definition: sti.h:49
#define IStillImage_Initialize(p, a, b)
Definition: sti.h:137
Definition: sti.h:99
IUnknown IUnknown_inner
Definition: sti.c:49
IStillImageW IStillImageW_iface
Definition: sti.c:50
LONG ref
Definition: sti.c:52
IUnknown * outer_unk
Definition: sti.c:51
Definition: send.c:48
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t * LPDWORD
Definition: typedefs.h:59
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR pwszDeviceName
Definition: winddi.h:3556
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define STG_E_UNIMPLEMENTEDFUNCTION
Definition: winerror.h:2586
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193