how do I solve unbalance stack in visual basic 2012? - vb.net

This is error that I got
Additional Information: A call to PInvoke function 'cobawebcamsss!cobawebcamsss.Form1::SendMessage' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Here is the code :
Option Explicit On
Option Strict Off
Public Class Form1
Const WM_CAP As Short = &H400S
Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
Const WS_CHILD As Integer = &H40000000
Const WS_VISIBLE As Integer = &H10000000
Const SWP_NOMOVE As Short = &H2S
Const SWP_NOSIZE As Short = 1
Const SWP_NOZORDER As Short = &H4S
Const HWND_BOTTOM As Short = 1
Dim iDevice As Integer = 0
Dim hHwnd As Integer
' Declare Function
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Object) As Integer
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (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 DestroyWindow Lib "user32" (ByVal hndw As Integer) As Boolean
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
Private Sub LoadDeviceList()
Dim strName As String = Space(100)
Dim strVer As String = Space(100)
Dim bReturn As Boolean
Dim x As Integer = 0
Do
bReturn = capGetDriverDescriptionA(x, strName, 100, strVer, 100)
If bReturn Then lstDevices.Items.Add(strName.Trim)
x += 1
Loop Until bReturn = False
End Sub
Private Sub OpenPreviewWindow()
Dim iHeight As Integer = picCapture.Height
Dim iWidth As Integer = picCapture.Width
hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, picCapture.Handle.ToInt32, 0)
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, picCapture.Width, picCapture.Height, SWP_NOMOVE Or SWP_NOZORDER)
btnSave.Enabled = True
btnStop.Enabled = True
btnStart.Enabled = False
Else
DestroyWindow(hHwnd)
btnSave.Enabled = False
End If
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim data As IDataObject
Dim bmap As Image
SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
data = Clipboard.GetDataObject()
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
picCapture.Image = bmap
ClosePreviewWindow()
btnSave.Enabled = False
btnStop.Enabled = False
btnStart.Enabled = True
If sfdImage.ShowDialog = DialogResult.OK Then
bmap.Save(sfdImage.FileName, Imaging.ImageFormat.Bmp)
End If
End If
End Sub
Private Sub ClosePreviewWindow()
SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0)
DestroyWindow(hHwnd)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadDeviceList()
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
OpenPreviewWindow()
btnStart.Enabled = False
btnStop.Enabled = True
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
ClosePreviewWindow()
btnStart.Enabled = True
btnStop.Enabled = False
End Sub
End Class
and it got highlighted here when I break the operation
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
please help, I am new in visual basic so I try to learn from others program but it didn't work, it is originally from visual basic 2010 and I copied it to visual basic 2012

If you are getting an error about PInvoke..SendMessage, try replacing the line:
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Object) As Integer
With:
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByRef RECT As IntPtr) As IntPtr
After that, worked fine on my Win7 x64.

Related

Set cursor position

So i have this code, i need to be able to move the cursor to a position but i need to get the position from listbox,and move the cursor to all the values,after move was done item to be deleted
Imports System.Drawing.Imaging
Imports System.Runtime.InteropServices
Imports System.Collections.Generic
Public Class Form1
Declare Auto Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As IntPtr)
Const MOUSEEVENTF_LEFTDOWN As Integer = &H2
Const MOUSEEVENTF_LEFTUP As Integer = &H4
Public Declare Auto Function SetCursorPos Lib "User32.dll" (ByVal X As Integer, ByVal Y As Integer) As Long
Public Declare Auto Function GetCursorPos Lib "User32.dll" (ByRef lpPoint As Point) As Long
Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20 ' middle button down
Public Const MOUSEEVENTF_MIDDLEUP = &H40 ' middle button up
Public Const MOUSEEVENTF_RIGHTDOWN = &H8 ' right button down
Public Const MOUSEEVENTF_RIGHTUP = &H10 ' right button up
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Dim speed As Integer = 1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Dim c As Color
' c = Image.GetPixel()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim tempPos As Point
Dim R As Long = GetCursorPos(tempPos)
' Label1.Text = "Mouse helye:" + tempPos.ToString + " :)"
Dim bmp As New Bitmap(80, 80)
' Using bmp As New Bitmap(30, 30)
Using g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(Windows.Forms.Cursor.Position, _
New Point(0, 0), New Size(1, 1))
End Using
Label1.Text = bmp.GetPixel(0, 0).ToString
' Me.Invalidate()
' End Using
If Label1.Text = "Color [A=255, R=0, G=163, B=232]" Then
ListBox1.Items.Add(tempPos.X)
ListBox2.Items.Add(tempPos.Y)
Cursor.Position = New Point(Cursor.Position.X + 20 * speed, Cursor.Position.Y)
Else
Cursor.Position = New Point(Cursor.Position.X + 20 * speed, Cursor.Position.Y)
' If ListBox1.Items.Contains(tempPos.X) And Listbox2.items.contains(tempPos.Y) Then
' Else
' ListBox1.Items.Add(tempPos.X)
' ListBox2.Items.Add(tempPos.Y)
' End If
End If
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Dim D As Boolean
Dim S As Boolean
D = GetAsyncKeyState(Keys.D)
S = GetAsyncKeyState(Keys.S)
If S = True Then
Timer1.Start()
End If
If D = True Then
Timer1.Stop()
End If
End Sub
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
End Sub
End Class
I use this code to fix the error,thank you Visual Vincent for help.
ListBox1.Items.Add(Cursor.Position.X & ";" & Cursor.Position.Y)
For Each item In ListBox1.Items
Dim s As String = item.ToString
Dim words As String() = s.Split(";")
Cursor.Position = New Point(words(0), words(1))
Next

"CallbackOnCollectedDelegate was detected"

I am trying to disable windows keys. Bt while running the application i get an error "CallbackOnCollectedDelegate was detected" Below is my code
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As LowLevelKeyboardProcDelegate, ByVal hMod As IntPtr, ByVal dwThreadId As Integer) As IntPtr
Declare Function UnhookWindowsHookEx Lib "user32" Alias "UnhookWindowsHookEx" (ByVal hHook As IntPtr) As Boolean
Declare Function CallNextHookEx Lib "user32" Alias "CallNextHookEx" (ByVal hHook As IntPtr, ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Delegate Function LowLevelKeyboardProcDelegate(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Const WH_KEYBOARD_LL As Integer = 13
Structure KBDLLHOOKSTRUCT
Dim vkCode As Integer
Dim scanCode As Integer
Dim flags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
End Structure
Dim intLLKey As IntPtr
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, IntPtr.Zero, 0)
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
UnhookWindowsHookEx(intLLKey)
End Sub
Private Function LowLevelKeyboardProc(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Dim blnEat As Boolean = False
Select Case wParam
Case 256, 257, 260, 261
'Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
blnEat = ((lParam.vkCode = 9) AndAlso (lParam.flags = 32)) Or
((lParam.vkCode = 27) AndAlso (lParam.flags = 32)) Or
((lParam.vkCode = 27) AndAlso (lParam.flags = 0)) Or
((lParam.vkCode = 91) AndAlso (lParam.flags = 1)) Or
((lParam.vkCode = 92) AndAlso (lParam.flags = 1))
End Select
If blnEat = True Then
Return 1
Else
Return CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam)
End If
End Function
Any help is very much appreciated
The issue is the same as this post. The difference being that they're using C#. However, VB is doing the same thing; generating a delegate for you. For reference, this is what the decompiled code looks like in your form's Load event.
Private Sub Form1_Load(sender As Object, e As EventArgs)
Me.intLLKey = Form1.SetWindowsHookEx(13, New Form1.LowLevelKeyboardProcDelegate(Me.LowLevelKeyboardProc), IntPtr.Zero, 0)
End Sub
Note that it's creating a LowLevelKeyboardProcDelegate delegate for you. I won't completely rehash #HansPassant's answer here, as he does an excellent job describing the problem and solution; only say that you'll need to store your own reference to the LowLevelKeyboardProcDelegate delegate.

VB.Net api affects windows forms

I am creating a application in vb.net and i am using some API functions.For example : GetForegroundWindow,SetWindowPos .So my app should change the active window's size and position when clicked.But it is affecting also the system forms like taskbar , StartMenu.How can i avoid this?
<Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Integer
End Function ''SETTTING THE WINDOW POSITION
<Runtime.InteropServices.DllImport("user32.dll")> _
Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short
End Function
<Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function GetForegroundWindow() As IntPtr
End Function
Private ReadOnly HWND_TOP As New IntPtr(0)
Public Const SWP_FRAMECHANGED As Integer = &H20
Dim cX As Integer, cY As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
cX = CInt(Windows.Forms.Cursor.Position.X.ToString())
cY = CInt(Windows.Forms.Cursor.Position.Y.ToString())
If GetAsyncKeyState(1) <> 0 Then
If cX <= 10 Then
If GetForegroundWindow() <> 1 Then
SetWindowPos(GetForegroundWindow(), HWND_TOP, 0, 0, 100, 100, SWP_FRAMECHANGED)
End If
End If
End If
End Sub
<Runtime.InteropServices.DllImport("User32")>
Public Shared Function GetWindowThreadProcessId(hWnd As IntPtr, ByRef lpdwProcessId As IntPtr) As IntPtr
End Function
Private Sub Button1_Click() Handles Button1.Click
Dim ID As IntPtr, hWnd As IntPtr '// hWnd By GetForegroundWindow
GetWindowThreadProcessId(hWnd, ID)
If Process.GetProcessById(ID).ProcessName.ToLower <> "Explorer".ToLower Then 'Without.exe
MessageBox.Show("Set Position")
End If
End Sub

How can i programmatically click a external Application Using VB.net

I have created a test software to test our product, but in some cases other customer provide there API/Tool and etc... to test there specific parameter.
I want is to click the button on other the application (Automatically Click).
Basically we want it so the operator will not click the wrong button even there have a work instruction.
Try this:
Private Const BM_CLICK = &HF5
Private Declare Auto Function FindWindow Lib "user32.dll" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
Private Declare Auto Function FindWindowEx Lib "user32.dll" (ByVal hwndParent As IntPtr, ByVal hwndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As IntPtr
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim hWndMsgBox, hWndButton As Long
hWndMsgBox = FindWindow("#32770", "About")
If hWndMsgBox Then hWndButton = FindWindowEx(hWndMsgBox, 0&, "Button", "OK")
If hWndButton Then SendMessage(hWndButton, BM_CLICK, 0&, 0&)
End Sub
'------------------------------FORM-----------------------------------------------
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
LeftClick()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If CommandType.Text = "Start" Then
Timer1.Enabled = True
CommandType.Text = "Stop"
Else
Timer1.Enabled = False
CommandType.Text = "Start"
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MoveMouse(300, 75)
LeftClick()
LeftClick()
End Sub
End Class
'------------------------------MODULE----------------------------------------------
Module Module1
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Integer, ByVal y As Integer) As Integer
Public Declare Function GetCursorPos Lib "user32" (ByVal lpPoint As POINTAPI) As Integer
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Public Const MOUSEEVENTF_MIDDLEUP = &H40
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Public Const MOUSEEVENTF_MOVE = &H1
Public Structure POINTAPI
Dim x As Integer
Dim y As Integer
End Structure
Public Function GetX() As Integer
: Dim n As POINTAPI
GetCursorPos(n)
GetX = n.x
End Function
Public Function GetY() As Integer
Dim n As POINTAPI
GetCursorPos(n)
GetY = n.y
End Function
Public Sub LeftClick()
LeftDown()
LeftUp()
End Sub
Public Sub LeftDown()
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
End Sub
Public Sub LeftUp()
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub
Public Sub MiddleClick()
MiddleDown()
MiddleUp()
End Sub
Public Sub MiddleDown()
mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
End Sub
Public Sub MiddleUp()
mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
End Sub
Public Sub RightClick()
RightDown()
RightUp()
End Sub
Public Sub RightDown()
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
End Sub
Public Sub RightUp()
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
End Sub
Public Sub MoveMouse(ByVal xMove As Integer, ByVal yMove As Integer)
mouse_event(MOUSEEVENTF_MOVE, xMove, yMove, 0, 0)
End Sub
Public Sub SetMousePos(ByVal xPos As Integer, ByVal yPos As Integer)
SetCursorPos(xPos, yPos)
End Sub
End Module
This will allow you to Left click, Right click and move cursor base on X and Y Axis.

Webcam light still on ever after disconnecting the drivers vb.net 2008

I want to capture image from webcam and I found an excellent code for that, the only problem is even after disconnecting webcam drivers webcam light still on. So it seems webcam still in use. How to adjust it?
SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, DeviceID, 0)
DestroyWindow(hHwnd)
Webcam Class
Public Class Form1
Const WM_CAP As Short = &H400S
Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
Public Const WM_CAP_GET_STATUS As Integer = WM_CAP + 54
Public Const WM_CAP_DLG_VIDEOFORMAT As Integer = WM_CAP + 41
Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
Const WS_CHILD As Integer = &H40000000
Const WS_VISIBLE As Integer = &H10000000
Const SWP_NOMOVE As Short = &H2S
Const SWP_NOSIZE As Short = 1
Const SWP_NOZORDER As Short = &H4S
Const HWND_BOTTOM As Short = 1
Private DeviceID As Integer = 0 ' Current device ID
Private hHwnd As Integer ' Handle to preview window
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
ByRef lParam As CAPSTATUS) As Boolean
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Boolean, _
ByRef lParam As Integer) As Boolean
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
ByRef lParam As Integer) As Boolean
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (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 DestroyWindow Lib "user32" (ByVal hndw As Integer) As Boolean
Structure POINTAPI
Dim x As Integer
Dim y As Integer
End Structure
Private Sub LoadDeviceList()
Dim strName As String = Space(100)
Dim strVer As String = Space(100)
Dim bReturn As Boolean
Dim x As Short = 0
'
' Load name of all avialable devices into the lstDevices
'
Do
'
' Get Driver name and version
'
bReturn = capGetDriverDescriptionA(x, strName, 100, strVer, 100)
'
' If there was a device add device name to the list
'
If bReturn Then lstDevices.Items.Add(strName.Trim)
x += CType(1, Short)
Loop Until bReturn = False
End Sub
Private Sub OpenPreviewWindow()
' Connect to device
'
SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, DeviceID, 0)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadDeviceList()
End Sub
Private Sub ClosePreviewWindow()
'
' Disconnect from device
'
SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, DeviceID, 0)
DestroyWindow(hHwnd)
End Sub
Start And Stop The Camera
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
DeviceID = lstDevices.SelectedIndex
OpenPreviewWindow()
Dim bReturn As Boolean
Dim s As CAPSTATUS
bReturn = SendMessage(hHwnd, WM_CAP_GET_STATUS, Marshal.SizeOf(s), s)
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
ClosePreviewWindow()
SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, DeviceID, 0)
End Sub
End Class