To have cameras used in WIN10 downgrade,
Traditional open camera methods are useless, a piece of black
In the camera - privacy, do not have permission to use this program switches,
Could you tell me who opened WIN10 cameras
CodePudding user response:
Normal module code:
Option Explicit
Private Declare Function capCreateCaptureWindow Lib "avicap32. DLL" _
Alias "capCreateCaptureWindowA" (_
ByVal lpszWindowName As String, _
ByVal dwStyle As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hWndParent As Long, _
ByVal nID As Long As Long)
Private Const WS_CHILD=& amp; H40000000
Private Const WS_VISIBLE=& amp; H10000000
Private Const WM_USER=& amp; H400
Private Const WM_CAP_START=& amp; H400
Private Const WM_CAP_EDIT_COPY=(WM_CAP_START + 30)
Private Const WM_CAP_DRIVER_CONNECT=(WM_CAP_START + 10)
Private Const WM_CAP_SET_PREVIEWRATE=(WM_CAP_START + 52)
Private Const WM_CAP_SET_OVERLAY=(WM_CAP_START + 51)
Private Const WM_CAP_SET_PREVIEW=(WM_CAP_START + 50)
Private Const WM_CAP_DRIVER_DISCONNECT=(WM_CAP_START + 11)
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (_
ByVal HWND As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
LParam As Long As Any)
Private Preview_Handle As Long
The Public Function CreateCaptureWindow (_
HWndParent As Long, _
Optional x As Long=0, _
Optional As Long=0, y _
Optional nWidth As Long=800, _
Optional nHeight As Long=600, _
Optional nCameraID As Long As Long=0)
On Error GoTo errhandle
Preview_Handle=capCreateCaptureWindow (" Video, "_
WS_CHILD + WS_VISIBLE, x, y, _
NWidth, nHeight, hWndParent, 1)
SendMessage Preview_Handle WM_CAP_DRIVER_CONNECT, nCameraID, 0
SendMessage Preview_Handle WM_CAP_SET_PREVIEWRATE, 30, 0
SendMessage Preview_Handle WM_CAP_SET_OVERLAY, 1, 0
SendMessage Preview_Handle WM_CAP_SET_PREVIEW, 1, 0
CreateCaptureWindow=Preview_Handle
The Exit Function
Errhandle:
MsgBox Err. The Description
End the Function
The Public Function CapturePicture (nCaptureHandle As Long) As StdPicture
The Clipboard. The Clear
SendMessage nCaptureHandle WM_CAP_EDIT_COPY, 0, 0
The Set CapturePicture=Clipboard. GetData
End the Function
Public Sub Disconnect (nCaptureHandle As Long, _
Optional nCameraID=0)
SendMessage nCaptureHandle WM_CAP_DRIVER_DISCONNECT, _
NCameraID, 0
End Sub
CodePudding user response:
Put a picturebox, new form, a timer two buttons,Code is as follows:
Option Explicit
Dim Video_Handle As Long
'connect camera
Public Sub LinkCam ()
On the Error Resume Next
Video_Handle=CreateCaptureWindow (Picture1. The HWND, 0, 0, Picture1. Width, Picture1. Height)
DoEvents
Timer1. Interval=25
Timer1. Enabled=True
End Sub
'broken camera
Public Sub DiscontCam ()
On the Error Resume Next
Timer1. Enabled=False
Picture1. Cls
Timer1. Enabled=False
Disconnect Video_Handle
End Sub
Private Sub Command1_Click ()
LinkCam
End Sub
Private Sub Command2_Click ()
DiscontCam
End Sub
Private Sub Form_Load ()
Me. The ScaleMode=3
Picture1. ScaleMode=3
End Sub
Private Sub Timer1_Timer ()
On the Error Resume Next
Dim sp As New StdPicture
Picture1. Cls
The Set of sp=CapturePicture (Video_Handle)
Picture1. PaintPicture sp, 0, 0
End Sub
CodePudding user response:
Method of efficiency is not high, but simple, and effective under Win10,CodePudding user response:
Can't open or a piece of black but also is not an error, didn't suspended animation program is a piece of blackI am WIN10 tablet millet 2
CodePudding user response:
To get the code, no, tracking, said a phenomenon you spent half a day reply unknowingly creditors, such asWhy not an Error, because inside a pile On the Error Resume Next
Put On the Error Resume Next all commented,
Single-step tracking, see Video_Handle to value