Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
Available now!
Buy at Amazon US or
Buy at Amazon UK



Articles

» Windows API reference
» Webcam streaming in VB.NET
» Remoting with firewalls
» RSA from first principles
» Key & MouseLogger in .NET
» Networking Resource Kit for .NET
» Migrating VB6 Winsock to VB.NET
» Migrating C++ sockets to C#
» RFC Reference guide
» COM Reference guide
» WMI Reference guide
» SQL stored procedures
» TCP & UDP port reference
» NET Framework reference
» Ethernet Type codes
» MAC address assignments
» DLL entry point reference
» Boost SQL performance
» Free SMS UK
» Free SMS Ireland
» Free SMS South Africa
» Internet Explorer

Contact us

Public Const WM_CAP_DRIVER_CONNECT As Integer = WM_USER + 10

Public Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_USER + 11

Public Const WM_CAP_SET_VIDEOFORMAT As Integer = WM_USER + 45

Public Const WM_CAP_SET_PREVIEW As Integer = WM_USER + 50

Public Const WM_CAP_SET_PREVIEWRATE As Integer = WM_USER + 52

The video format is defined in terms of a bitmap, so we must define our standard bitmap structure

    Public Structure BITMAPINFOHEADER

        Dim biSize As Integer

        Dim biWidth As Integer

        Dim biHeight As Integer

        Dim biPlanes As Short

        Dim biBitCount As Short

        Dim biCompression As Integer

        Dim biSizeImage As Integer

        Dim biXPelsPerMeter As Integer

        Dim biYPelsPerMeter As Integer

        Dim biClrUsed As Integer

        Dim biClrImportant As Integer

    End Structure

    Public Structure BITMAPINFO

        Dim bmiHeader As BITMAPINFOHEADER

        Dim bmiColors() As Integer

    End Structure

Now we start getting down-and-dirty into the API, these calls are where the real magic happens. The first three API calls, SetWindowPos, SendMessage, and SendMessageAsBitmap (usually called SendMessageAsAny) are standard windows API calls, and are usually used to position application windows, and send windows messages to them. In our case the application window, is in fact a webcam capture window, and responds to a special set of windows messages.

The capCreateCaptureWindow and capGetDriverDescription are from the Video For Windows API. The former API function is used to create a new webcam capture window, and map a VFW driver to it. The latter API function is used to enumerate VFW devices, such as Webcams on the system.

Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer

    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Short, ByVal lParam As Integer) As Integer

    Declare Function SendMessageAsBitMap Lib "user32" Alias "SendMessageA" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As BITMAPINFO) As Integer

    Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Short, ByVal hWndParent As Integer, ByVal nID As Integer) As Integer

    Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, ByVal cbVer As Integer) As Boolean

   

Page 1  Page 3 



Google

Copyright 2017 Infinite Loop Ltd.