ReactOS  0.4.13-dev-39-g8b6696f
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 
33 LRESULT
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 
49  return DefWindowProc(hwnd, Msg, wParam, lParam);
50 }
51 
52 
53 /* FUNCTIONS ***********************************************************/
54 
55 /*
56  * implemented
57  */
58 HWND
59 VFWAPI
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";
70  WNDCLASSEXW WndClass = {0};
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;
79  WndClass.style = CS_HREDRAW | CS_VREDRAW;
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),
98  hInstance,
99  NULL);
100 }
101 
102 /*
103  * implemented
104  */
105 HWND
106 VFWAPI
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  */
140 BOOL
141 VFWAPI
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,
178  NULL, NULL) == ERROR_SUCCESS)
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,
189  &dwSize) == ERROR_SUCCESS)
190  {
191  dwSize = sizeof(szDriverName);
192 
193  if (RegQueryValueExW(hSubKey,
194  L"FriendlyName",
195  NULL,
196  NULL,
198  &dwSize) != ERROR_SUCCESS)
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);
243  RegCloseKey(hKey);
244  return TRUE;
245  }
246  }
247 
248  RegCloseKey(hSubKey);
249  }
250 
251  dwSize = sizeof(szDriver) / sizeof(WCHAR);
252  dwIndex++;
253  }
254 
255  RegCloseKey(hKey);
256 
257  return FALSE;
258 }
259 
260 
261 /*
262  * implemented
263  */
264 BOOL
265 VFWAPI
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  */
289 VOID
290 VFWAPI
292 {
294 }
295 
296 
297 /*
298  * unimplemented
299  */
300 DWORD
301 VFWAPI
302 videoThunk32(DWORD dwUnknown1, DWORD dwUnknown2, DWORD dwUnknown3, DWORD dwUnknown4, DWORD dwUnknown5)
303 {
305  return 0;
306 }
307 
308 
309 BOOL
310 WINAPI
312  IN DWORD dwReason,
314 {
315  switch (dwReason)
316  {
317  case DLL_PROCESS_ATTACH:
318  TRACE("avicap32 attached!\n");
319  hInstance = hinstDLL;
320  break;
321  }
322 
323  return TRUE;
324 }
#define GetFileVersionInfo
Definition: winver.h:54
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define IN
Definition: typedefs.h:38
#define ULongToHandle(h)
Definition: basetsd.h:81
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
VOID VFWAPI AppCleanup(HINSTANCE hInst)
Definition: avicap32.c:291
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:101
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WORD ATOM
Definition: dimm.idl:113
#define KEY_READ
Definition: nt_native.h:1023
#define CP_ACP
Definition: compat.h:99
#define GetFileVersionInfoSize
Definition: winver.h:53
#define CALLBACK
Definition: compat.h:27
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CS_HREDRAW
Definition: winuser.h:648
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
struct @1567 Msg[]
HWND VFWAPI capCreateCaptureWindowA(LPCSTR lpszWindowName, DWORD dwStyle, INT x, INT y, INT nWidth, INT nHeight, HWND hWnd, INT nID)
Definition: avicap32.c:107
UINT_PTR WPARAM
Definition: windef.h:207
HWND VFWAPI capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, INT x, INT y, INT nWidth, INT nHeight, HWND hWnd, INT nID)
Definition: avicap32.c:60
struct _WNDCLASSEXW WNDCLASSEXW
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
static IN DWORD IN LPVOID lpvReserved
#define lstrcpynW
Definition: compat.h:397
WINE_DEFAULT_DEBUG_CHANNEL(avicap32)
LRESULT CALLBACK CaptureWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: avicap32.c:35
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
DWORD dwReason
Definition: misc.cpp:154
const TCHAR szWindowClass[]
Definition: magnifier.c:29
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
#define FIXME(fmt,...)
Definition: debug.h:110
struct NameRec_ * Name
Definition: cdprocs.h:464
BOOL VFWAPI capGetDriverDescriptionA(WORD wDriverIndex, LPSTR lpszName, INT cbName, LPSTR lpszVer, INT cbVer)
Definition: avicap32.c:266
smooth NULL
Definition: ftsmooth.c:416
_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:426
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI DllMain(IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
Definition: avicap32.c:311
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
const char * LPCSTR
Definition: xmlstorage.h:183
static const WCHAR szDriverName[]
Definition: provider.c:66
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define CS_VREDRAW
Definition: winuser.h:653
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WINAPI
Definition: msvc.h:8
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define WM_PAINT
Definition: winuser.h:1602
static LPCWSTR szVersion
Definition: asmcache.c:748
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
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)
#define COLOR_BTNFACE
Definition: winuser.h:918
void Ls(const char *const item, int listmode, const char *const options, FILE *stream)
Definition: ls.c:465
#define VFWAPI
Definition: vfw.h:26
HINSTANCE hInst
Definition: dxdiag.c:13
#define CAP_DESC_MAX
Definition: avicap32.c:23
DWORD VFWAPI videoThunk32(DWORD dwUnknown1, DWORD dwUnknown2, DWORD dwUnknown3, DWORD dwUnknown4, DWORD dwUnknown5)
Definition: avicap32.c:302
unsigned int UINT
Definition: ndis.h:50
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define IDC_ARROW
Definition: winuser.h:682
#define WM_CREATE
Definition: winuser.h:1590
struct FileInfo FileInfo
#define HIWORD(l)
Definition: typedefs.h:246
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define UNIMPLEMENTED
Definition: debug.h:114
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:2541
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
HINSTANCE hInstance
Definition: avicap32.c:28
WCHAR WndClass[]
Definition: capicon.c:23
BOOL VFWAPI capGetDriverDescriptionW(WORD wDriverIndex, LPWSTR lpszName, INT cbName, LPWSTR lpszVer, INT cbVer)
Definition: avicap32.c:142
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1054
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12