ReactOS 0.4.17-dev-966-gf06eace
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 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\StillImage\\Registered Applications";
40
41typedef struct _stillimage
42{
44 IStillImageW IStillImageW_iface;
48
49static inline stillimage *impl_from_IStillImageW(IStillImageW *iface)
50{
51 return CONTAINING_RECORD(iface, stillimage, IStillImageW_iface);
52}
53
54static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID riid, void **ppvObject)
55{
57 TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
58 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObject);
59}
60
61static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface)
62{
64 return IUnknown_AddRef(This->outer_unk);
65}
66
67static ULONG WINAPI stillimagew_Release(IStillImageW *iface)
68{
70 return IUnknown_Release(This->outer_unk);
71}
72
74{
76 TRACE("(%p, %p, 0x%lX)\n", This, hinst, dwVersion);
77 return S_OK;
78}
79
80static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwType, DWORD dwFlags,
81 DWORD *pdwItemsReturned, LPVOID *ppBuffer)
82{
84 FIXME("(%p, %lu, 0x%lX, %p, %p): stub\n", This, dwType, dwFlags, pdwItemsReturned, ppBuffer);
85 return E_NOTIMPL;
86}
87
89 LPVOID *ppBuffer)
90{
92 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), ppBuffer);
93 return E_NOTIMPL;
94}
95
97 PSTIDEVICEW *pDevice, LPUNKNOWN pUnkOuter)
98{
100 FIXME("(%p, %s, %lu, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), dwMode, pDevice, pUnkOuter);
101 return E_NOTIMPL;
102}
103
104static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
106{
108 FIXME("(%p, %s, %s, %p, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
109 pType, pData, cbData);
110 return E_NOTIMPL;
111}
112
113static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
115{
117 FIXME("(%p, %s, %s, %lu, %p, %lu): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
118 type, pData, cbData);
119 return E_NOTIMPL;
120}
121
123 DWORD *pdwEventCode, LPWSTR pwszEventName)
124{
126 FIXME("(%p, %p, %p, %p): stub\n", This, pwszDeviceName,
127 pdwEventCode, pwszEventName);
128 return E_NOTIMPL;
129}
130
131static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName,
132 LPWSTR pwszCommandLine)
133{
134 static const WCHAR commandLineSuffix[] = L"/StiDevice:%1 /StiEvent:%2";
135 HKEY registeredAppsKey = NULL;
136 DWORD ret;
137 HRESULT hr = S_OK;
139
140 TRACE("(%p, %s, %s)\n", This, debugstr_w(pwszAppName), debugstr_w(pwszCommandLine));
141
143 if (ret == ERROR_SUCCESS)
144 {
145 size_t len = lstrlenW(pwszCommandLine) + 1 + lstrlenW(commandLineSuffix) + 1;
146 WCHAR *value = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
147 if (value)
148 {
149 swprintf(value, len, L"%s %s", pwszCommandLine, commandLineSuffix);
150 ret = RegSetValueExW(registeredAppsKey, pwszAppName, 0,
151 REG_SZ, (BYTE*)value, (lstrlenW(value)+1)*sizeof(WCHAR));
152 if (ret != ERROR_SUCCESS)
155 }
156 else
158 RegCloseKey(registeredAppsKey);
159 }
160 else
162 return hr;
163}
164
165static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName)
166{
168 HKEY registeredAppsKey = NULL;
169 DWORD ret;
170 HRESULT hr = S_OK;
171
172 TRACE("(%p, %s)\n", This, debugstr_w(pwszAppName));
173
175 if (ret == ERROR_SUCCESS)
176 {
177 ret = RegDeleteValueW(registeredAppsKey, pwszAppName);
178 if (ret != ERROR_SUCCESS)
180 RegCloseKey(registeredAppsKey);
181 }
182 else
184 return hr;
185}
186
188 BOOL bNewState)
189{
191 FIXME("(%p, %s, %u): stub\n", This, debugstr_w(pwszDeviceName), bNewState);
192 return E_NOTIMPL;
193}
194
196 BOOL *pbCurrentState)
197{
199 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), pbCurrentState);
200 return E_NOTIMPL;
201}
202
204{
206 FIXME("(%p, %s): stub\n", This, debugstr_w(pwszDeviceName));
207 return E_NOTIMPL;
208}
209
211 LPWSTR pwszAppName, LPSTINOTIFY pStiNotify)
212{
214 FIXME("(%p, %s, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pwszAppName),
215 pStiNotify);
216 return E_NOTIMPL;
217}
218
220{
222 FIXME("(%p, %p): stub\n", This, pDevInfo);
223 return E_NOTIMPL;
224}
225
226static HRESULT WINAPI stillimagew_WriteToErrorLog(IStillImageW *iface, DWORD dwMessageType, LPCWSTR pszMessage)
227{
229 FIXME("(%p, %lu, %s): stub\n", This, dwMessageType, debugstr_w(pszMessage));
230 return E_NOTIMPL;
231}
232
233static const struct IStillImageWVtbl stillimagew_vtbl =
234{
253};
254
256{
257 return CONTAINING_RECORD(iface, stillimage, IUnknown_inner);
258}
259
260static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
261{
263
264 TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
265
267 *ppvObject = iface;
268 else if (IsEqualGUID(riid, &IID_IStillImageW))
269 *ppvObject = &This->IStillImageW_iface;
270 else
271 {
272 if (IsEqualGUID(riid, &IID_IStillImageA))
273 FIXME("interface IStillImageA is unsupported on Windows Vista too, please report if it's needed\n");
274 else
275 FIXME("interface %s not implemented\n", debugstr_guid(riid));
276 *ppvObject = NULL;
277 return E_NOINTERFACE;
278 }
279
280 IUnknown_AddRef((IUnknown*) *ppvObject);
281 return S_OK;
282}
283
285{
287 return InterlockedIncrement(&This->ref);
288}
289
291{
292 ULONG ref;
294
296 if (ref == 0)
298 return ref;
299}
300
301static const struct IUnknownVtbl internal_unk_vtbl =
302{
306};
307
308/******************************************************************************
309 * StiCreateInstanceA (STI.@)
310 */
312{
313 FIXME("(%p, %lu, %p, %p): stub, unimplemented on Windows Vista too, please report if it's needed\n", hinst, dwVer, ppSti, pUnkOuter);
315}
316
317/******************************************************************************
318 * StiCreateInstanceW (STI.@)
319 */
321{
323 HRESULT hr;
324
325 TRACE("(%p, %lu, %p, %p)\n", hinst, dwVer, ppSti, pUnkOuter);
326
328 if (This)
329 {
330 This->IStillImageW_iface.lpVtbl = &stillimagew_vtbl;
331 This->IUnknown_inner.lpVtbl = &internal_unk_vtbl;
332 if (pUnkOuter)
333 This->outer_unk = pUnkOuter;
334 else
335 This->outer_unk = &This->IUnknown_inner;
336 This->ref = 1;
337
338 hr = IStillImage_Initialize(&This->IStillImageW_iface, hinst, dwVer);
339 if (SUCCEEDED(hr))
340 {
341 if (pUnkOuter)
342 *ppSti = (IStillImageW*) &This->IUnknown_inner;
343 else
344 *ppSti = &This->IStillImageW_iface;
345 }
346 }
347 else
349
350 return hr;
351}
#define REG_SZ
Definition: layer.c:22
#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
HRESULT hr
Definition: delayimp.cpp:582
#define ERROR_SUCCESS
Definition: deptool.c:10
static LPVOID LPUNKNOWN
Definition: dinput.c:53
#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:122
static HRESULT WINAPI stillimagew_GetHwNotificationState(IStillImageW *iface, LPCWSTR pwszDeviceName, BOOL *pbCurrentState)
Definition: sti.c:195
static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface)
Definition: sti.c:61
static ULONG WINAPI Internal_AddRef(IUnknown *iface)
Definition: sti.c:284
static HRESULT WINAPI stillimagew_RefreshDeviceBus(IStillImageW *iface, LPCWSTR pwszDeviceName)
Definition: sti.c:203
HRESULT WINAPI StiCreateInstanceA(HINSTANCE hinst, DWORD dwVer, PSTIA *ppSti, LPUNKNOWN pUnkOuter)
Definition: sti.c:311
HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LPUNKNOWN pUnkOuter)
Definition: sti.c:320
static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
Definition: sti.c:260
static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName)
Definition: sti.c:165
static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName, LPWSTR pwszCommandLine)
Definition: sti.c:131
static const struct IStillImageWVtbl stillimagew_vtbl
Definition: sti.c:233
static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwType, DWORD dwFlags, DWORD *pdwItemsReturned, LPVOID *ppBuffer)
Definition: sti.c:80
static const WCHAR registeredAppsLaunchPath[]
Definition: sti.c:38
static stillimage * impl_from_IStillImageW(IStillImageW *iface)
Definition: sti.c:49
static HRESULT WINAPI stillimagew_CreateDevice(IStillImageW *iface, LPWSTR pwszDeviceName, DWORD dwMode, PSTIDEVICEW *pDevice, LPUNKNOWN pUnkOuter)
Definition: sti.c:96
static HRESULT WINAPI stillimagew_LaunchApplicationForDevice(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pwszAppName, LPSTINOTIFY pStiNotify)
Definition: sti.c:210
struct _stillimage stillimage
static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID riid, void **ppvObject)
Definition: sti.c:54
static ULONG WINAPI stillimagew_Release(IStillImageW *iface)
Definition: sti.c:67
static HRESULT WINAPI stillimagew_SetupDeviceParameters(IStillImageW *iface, PSTI_DEVICE_INFORMATIONW pDevInfo)
Definition: sti.c:219
static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hinst, DWORD dwVersion)
Definition: sti.c:73
static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName, DWORD type, LPBYTE pData, DWORD cbData)
Definition: sti.c:113
static HRESULT WINAPI stillimagew_WriteToErrorLog(IStillImageW *iface, DWORD dwMessageType, LPCWSTR pszMessage)
Definition: sti.c:226
static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPCWSTR pwszDeviceName, BOOL bNewState)
Definition: sti.c:187
static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName, LPDWORD pType, LPBYTE pData, LPDWORD cbData)
Definition: sti.c:104
static ULONG WINAPI Internal_Release(IUnknown *iface)
Definition: sti.c:290
static HRESULT WINAPI stillimagew_GetDeviceInfo(IStillImageW *iface, LPWSTR pwszDeviceName, LPVOID *ppBuffer)
Definition: sti.c:88
static stillimage * impl_from_IUnknown(IUnknown *iface)
Definition: sti.c:255
static const struct IUnknownVtbl internal_unk_vtbl
Definition: sti.c:301
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
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
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
static HINSTANCE hinst
Definition: edit.c:551
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
_In_ DWORD dwVersion
Definition: netsh.h:85
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
#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:43
IStillImageW IStillImageW_iface
Definition: sti.c:44
LONG ref
Definition: sti.c:46
IUnknown * outer_unk
Definition: sti.c:45
Definition: send.c:48
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
const uint16_t * LPCWSTR
Definition: typedefs.h:57
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
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:64
_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
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define E_NOINTERFACE
Definition: winerror.h:3479
#define STG_E_UNIMPLEMENTEDFUNCTION
Definition: winerror.h:3682
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
unsigned char BYTE
Definition: xxhash.c:193