ReactOS 0.4.15-dev-7788-g1ad9096
avicap32.c
Go to the documentation of this file.
1/*
2 * PROJECT: avicap32
3 * FILE: dll\win32\avicap32\avicap32.c
4 * PURPOSE: Main file
5 * PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
6 */
7
8#define WIN32_NO_STATUS
9#define _INC_WINDOWS
10#define COM_NO_WINDOWS_H
11
12#include <stdio.h>
13#include <windef.h>
14#include <winbase.h>
15#include <winreg.h>
16#include <winver.h>
17#include <winnls.h>
18#include <wingdi.h>
19#include <winternl.h>
20#include <vfw.h>
21#include <wine/debug.h>
22
23#define CAP_DESC_MAX 32
24
26
27
29
30
31/* INTRENAL FUNCTIONS **************************************************/
32
36{
37 switch (Msg)
38 {
39 case WM_CREATE:
40 break;
41
42 case WM_PAINT:
43 break;
44
45 case WM_DESTROY:
46 break;
47 }
48
50}
51
52
53/* FUNCTIONS ***********************************************************/
54
55/*
56 * implemented
57 */
58HWND
61 DWORD dwStyle,
62 INT x,
63 INT y,
64 INT nWidth,
65 INT nHeight,
66 HWND hWnd,
67 INT nID)
68{
69 WCHAR szWindowClass[] = L"ClsCapWin";
71 DWORD dwExStyle = 0;
72
73 FIXME("capCreateCaptureWindowW() not fully implemented!\n");
74
75 WndClass.cbSize = sizeof(WNDCLASSEXW);
76 WndClass.lpszClassName = szWindowClass;
77 WndClass.lpfnWndProc = CaptureWindowProc; /* TODO: Implement CaptureWindowProc */
78 WndClass.hInstance = hInstance;
80 WndClass.hCursor = LoadCursorW(0, IDC_ARROW);
81 WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
82
83 if (RegisterClassExW(&WndClass) == (ATOM)0)
84 {
86 return NULL;
87 }
88
89 return CreateWindowExW(dwExStyle,
91 lpszWindowName,
92 dwStyle,
93 x, y,
94 nWidth,
95 nHeight,
96 hWnd,
97 ULongToHandle(nID),
99 NULL);
100}
101
102/*
103 * implemented
104 */
105HWND
106VFWAPI
108 DWORD dwStyle,
109 INT x,
110 INT y,
111 INT nWidth,
112 INT nHeight,
113 HWND hWnd,
114 INT nID)
115{
117 HWND Wnd;
118
119 if (lpszWindowName)
120 RtlCreateUnicodeStringFromAsciiz(&Name, lpszWindowName);
121 else
122 Name.Buffer = NULL;
123
124 Wnd = capCreateCaptureWindowW(Name.Buffer,
125 dwStyle,
126 x, y,
127 nWidth,
128 nHeight,
129 hWnd,
130 nID);
131
133 return Wnd;
134}
135
136
137/*
138 * implemented
139 */
140BOOL
141VFWAPI
143 LPWSTR lpszName,
144 INT cbName,
145 LPWSTR lpszVer,
146 INT cbVer)
147{
148 DWORD dwSize, dwIndex = 0;
149 WCHAR szDriver[MAX_PATH];
151 WCHAR szFileName[MAX_PATH];
153 HKEY hKey, hSubKey;
154
155 /* TODO: Add support of data acquisition from system.ini */
156 FIXME("capGetDriverDescriptionW() not fully implemented!\n");
157
158 if (lpszName && cbName)
159 lpszName[0] = L'\0';
160
161 if (lpszVer && cbVer)
162 lpszVer[0] = L'\0';
163
165 L"SYSTEM\\CurrentControlSet\\Control\\MediaResources\\msvideo",
166 0,
167 KEY_READ,
168 &hKey) != ERROR_SUCCESS)
169 {
170 return FALSE;
171 }
172
173 dwSize = sizeof(szDriver) / sizeof(WCHAR);
174
175 while (RegEnumKeyExW(hKey, dwIndex,
176 szDriver, &dwSize,
177 NULL, NULL,
179 {
180 if (RegOpenKeyW(hKey, szDriver, &hSubKey) == ERROR_SUCCESS)
181 {
182 dwSize = sizeof(szFileName);
183
184 if (RegQueryValueExW(hSubKey,
185 L"Driver",
186 NULL,
187 NULL,
188 (LPBYTE)&szFileName,
190 {
191 dwSize = sizeof(szDriverName);
192
193 if (RegQueryValueExW(hSubKey,
194 L"FriendlyName",
195 NULL,
196 NULL,
199 {
200 wcscpy(szDriverName, L"Unknown Driver Name");
201 }
202
203 if (dwIndex == (DWORD)wDriverIndex)
204 {
205 if (lpszName && cbName)
206 {
207 lstrcpynW(lpszName, szDriverName, cbName);
208 }
209
210 if (lpszVer && cbVer)
211 {
212 LPVOID Version, Ms;
213 DWORD dwInfoSize;
215 UINT Ls;
216
217 dwInfoSize = GetFileVersionInfoSize(szFileName, NULL);
218 if (dwInfoSize)
219 {
220 Version = HeapAlloc(GetProcessHeap(), 0, dwInfoSize);
221
222 if (Version != NULL)
223 {
224 GetFileVersionInfo(szFileName, 0, dwInfoSize, Version);
225
226 if (VerQueryValueW(Version, L"\\", &Ms, &Ls))
227 {
228 memmove(&FileInfo, Ms, Ls);
229 swprintf(szVersion, L"Version: %d.%d.%d.%d",
230 HIWORD(FileInfo.dwFileVersionMS),
231 LOWORD(FileInfo.dwFileVersionMS),
232 HIWORD(FileInfo.dwFileVersionLS),
233 LOWORD(FileInfo.dwFileVersionLS));
234
235 lstrcpynW(lpszVer, szVersion, cbVer);
236 }
238 }
239 }
240 }
241
242 RegCloseKey(hSubKey);
244 return TRUE;
245 }
246 }
247
248 RegCloseKey(hSubKey);
249 }
250
251 dwSize = sizeof(szDriver) / sizeof(WCHAR);
252 dwIndex++;
253 }
254
256
257 return FALSE;
258}
259
260
261/*
262 * implemented
263 */
264BOOL
265VFWAPI
267 LPSTR lpszName,
268 INT cbName,
269 LPSTR lpszVer,
270 INT cbVer)
271{
272 WCHAR DevName[CAP_DESC_MAX], DevVer[CAP_DESC_MAX];
273 BOOL Result;
274
275 Result = capGetDriverDescriptionW(wDriverIndex, DevName, CAP_DESC_MAX, DevVer, CAP_DESC_MAX);
276 if (Result)
277 {
278 WideCharToMultiByte(CP_ACP, 0, DevName, -1, lpszName, cbName, NULL, NULL);
279 WideCharToMultiByte(CP_ACP, 0, DevVer, -1, lpszVer, cbVer, NULL, NULL);
280 }
281
282 return Result;
283}
284
285
286/*
287 * unimplemented
288 */
289VOID
290VFWAPI
292{
294}
295
296
297/*
298 * unimplemented
299 */
300DWORD
301VFWAPI
302videoThunk32(DWORD dwUnknown1, DWORD dwUnknown2, DWORD dwUnknown3, DWORD dwUnknown4, DWORD dwUnknown5)
303{
305 return 0;
306}
307
308
309BOOL
310WINAPI
314{
315 switch (dwReason)
316 {
318 TRACE("avicap32 attached!\n");
319 hInstance = hinstDLL;
320 break;
321 }
322
323 return TRUE;
324}
struct NameRec_ * Name
Definition: cdprocs.h:460
#define CAP_DESC_MAX
Definition: avicap32.c:23
BOOL VFWAPI capGetDriverDescriptionW(WORD wDriverIndex, LPWSTR lpszName, INT cbName, LPWSTR lpszVer, INT cbVer)
Definition: avicap32.c:142
HWND VFWAPI capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, INT x, INT y, INT nWidth, INT nHeight, HWND hWnd, INT nID)
Definition: avicap32.c:60
LRESULT CALLBACK CaptureWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: avicap32.c:35
HINSTANCE hInstance
Definition: avicap32.c:28
BOOL WINAPI DllMain(IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
Definition: avicap32.c:311
DWORD VFWAPI videoThunk32(DWORD dwUnknown1, DWORD dwUnknown2, DWORD dwUnknown3, DWORD dwUnknown4, DWORD dwUnknown5)
Definition: avicap32.c:302
BOOL VFWAPI capGetDriverDescriptionA(WORD wDriverIndex, LPSTR lpszName, INT cbName, LPSTR lpszVer, INT cbVer)
Definition: avicap32.c:266
VOID VFWAPI AppCleanup(HINSTANCE hInst)
Definition: avicap32.c:291
HWND VFWAPI capCreateCaptureWindowA(LPCSTR lpszWindowName, DWORD dwStyle, INT x, INT y, INT nWidth, INT nHeight, HWND hWnd, INT nID)
Definition: avicap32.c:107
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
DWORD dwReason
Definition: misc.cpp:154
#define ULongToHandle(h)
Definition: basetsd.h:81
#define FIXME(fmt,...)
Definition: debug.h:111
#define UNIMPLEMENTED
Definition: debug.h:115
#define RegCloseKey(hKey)
Definition: registry.h:49
WCHAR WndClass[]
Definition: capicon.c:23
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
struct @1627 Msg[]
#define ERROR_SUCCESS
Definition: deptool.c:10
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR szDriverName[]
Definition: provider.c:69
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3362
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2533
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3297
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4132
#define GetProcessHeap()
Definition: compat.h:736
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define WideCharToMultiByte
Definition: compat.h:111
#define lstrcpynW
Definition: compat.h:738
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049
#define swprintf
Definition: precomp.h:40
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
FxAutoRegKey hKey
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static IN DWORD IN LPVOID lpvReserved
void Ls(const char *const item, int listmode, const char *const options, FILE *stream)
Definition: ls.c:465
const TCHAR szWindowClass[]
Definition: magnifier.c:28
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static LPCWSTR szVersion
Definition: asmcache.c:748
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define DefWindowProc
Definition: ros2win.h:31
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
#define HIWORD(l)
Definition: typedefs.h:247
#define VFWAPI
Definition: vfw.h:26
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define WM_PAINT
Definition: winuser.h:1620
#define CS_VREDRAW
Definition: winuser.h:658
#define WM_CREATE
Definition: winuser.h:1608
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2105
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
struct _WNDCLASSEXW WNDCLASSEXW
#define WM_DESTROY
Definition: winuser.h:1609
#define COLOR_BTNFACE
Definition: winuser.h:928
#define GetFileVersionInfo
Definition: winver.h:54
#define GetFileVersionInfoSize
Definition: winver.h:53
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185