C#: Error calling the camera on the tablet of Microsoft Surface-win10

public static extern bool capGetDriverDescriptionA(short wDriver, byte[] lpszName, int cbName, byte[] lpszVer, int cbVer);

public static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, int nID);

public static extern bool SendMessage(IntPtr hWnd, int wMsg, short wParam, int lParam);

public static extern bool SendMessage(IntPtr hWnd, int wMsg, bool wParam, int lParam);

public const int WM_USER = 0x400; 
public const int WS_CHILD = 0x40000000; 
public const int WS_VISIBLE = 0x10000000; 
public const int WM_CAP_DRIVER_CONNECT = WM_USER + 10; 
public const int WM_CAP_DRIVER_DISCONNECT = WM_USER + 11; 
public const int WM_CAP_SET_PREVIEW = WM_USER + 50; 
public const int WM_CAP_SET_PREVIEWRATE = WM_USER + 52; 

byte[] lpszName = new byte[100];
byte[] lpszVer = new byte[100];
capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100);
IntPtr lwndC = capCreateCaptureWindowA(lpszName, WS_VISIBLE + WS_CHILD, 0, 0, mWidth, mHeight, mControlPtr, 0);

//When the program runs to the following code, a camera selection dialog box (Microsoft Camera Front/Microsoft Camera Rear) appears. After selecting any of them, the code in the if statement is not executed,and the camera cannot run normally. Can anyone help me? Why is this happening, thank you.

if (SendMessage(lwndC, VideoAPI.WM_CAP_DRIVER_CONNECT, 0, 0))
    SendMessage(lwndC, WM_CAP_SET_PREVIEWRATE, 66, 0);
    SendMessage(lwndC, WM_CAP_SET_PREVIEW, true, 0);
asked on Stack Overflow Jan 11, 2021 by dj-allan

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0