English 中文(简体)
Webcam, 视频源对话框出现
原标题:webcam, Video Source dialog comes up

So have seen a ton of people with the same issue s but no answers. My SendMessage pop s up the "Video Source" dialog box on a windows 7 laptop with one camera. I have Cyber Link YouCam installed.  Video Source  dialog box

如果我卸载网络链接, “ Video 源代码” 对话框就会消失。 看来 OS 正在运行, 好像YouCam 是同一设备的第二个驱动程序 。 我的问题是我如何阻止“ Video 源代码” 的对话框出现? 一旦我在对话框中选择一个选项, 我将无法获取对话框( 直到我重新启动应用程序), 因此必须设置一个设置 。

尽管调试找到了这个部分的代码(见下文整节), 似乎是调用对话框的代码之一 — SendMessage (DeviceHandle, WM_CAP_CONNECT, 设备no, (IntPtr) 0 Toint32 () 。)

 public void StartWebCam (int height, int width, int handleofthepicturebox, int deviceno)
        {

        string deviceIndex = "" + deviceno;

        deviceHandle = capCreateCaptureWindowA (ref deviceIndex, WS_VISIBLE | WS_CHILD, 0, 0, width, height, handleofthepicturebox, 0);


        if (SendMessage (deviceHandle, WM_CAP_CONNECT, deviceno, ((IntPtr) 0).ToInt32 ()) > 0)
            {


            SendMessage (deviceHandle, WM_CAP_SET_SCALE, -1, 0);
            SendMessage (deviceHandle, WM_CAP_SET_PREVIEWRATE, 0x42, 0);
            SendMessage (deviceHandle, WM_CAP_SET_PREVIEW, -1, 0);

            }
        else
            {
            // nothing failed maybe some clean up needed
            }

        }

问题是,我该如何阻止“ Video Source” 的对话框出现?

最佳回答

我在Windows XP上开发了一张表, 以显示两个有 avicap32 的实时捕捉。 我找到的修复方法 有可能也适用于您的 。

在 avicap 的情况下, 可以用程序管理您的网络摄像头, 以及所有基于注册的图像。 这里是 < a href=" http://social. msdn.microsoft.com/Forums/ en- US/ vbgener/ thread/ c4fd12d8- 2870- 47ed-8f2e-3dc613afeb6f/" rel="no follow" > 我找到的线 < /a> 来指导我, 实现我的愿望。

在此线条中,在选择活动网络摄像头时,突出显示 <编码>HKEY_LOCOL_MACHINESYSTEM当前控制系统控制设备资源存储器的功能。 VFWWMDDDevicePath 注册键对选择活动网络摄像头的作用。

这或许是一个有用的信息:我不得不在小写中设定值以避免视频源对话出现。

我在调用 SendMessage WM_CAP_CONNECT 之前和之后对登记册键进行了监测,从而确定该键。

据我所知(和谷歌),没有其他人提出解决办法,所以尽管我可能回答晚了一点,但如果你能告诉我们它是否也对你有用,那将是件好事。

问题回答

Finally I Found a solution for this.
The problem happens in Windows 7 / 8

首先,您需要这个 API 函数

Private Declare Function GetTickCount Lib "kernel32" () As Long

然后... 在您调用 capcreate CaptapptureWindowA () 后, 您必须等待第二次处理事件, (注意: 睡眠不工作相同)

IniTime = GetTickCount()
While GetTickCount() < (IniTime + 1000)
   DoEvents
Wend

然后调用 WM_CAP_DRIVER_CONNECT (可能几次)。 。 这就是... 不再有视频源对话框 。

有了这个解决方案,它就能完美地工作。 GetTickCount () 等待事件运行,同时调用函数直到它返回真实状态 。

Private Sub PreviewVideo(ByVal pbCtrl As PictureBox)    
    hWnd = capCreateCaptureWindowA(VideoSource, WS_VISIBLE Or WS_CHILD, 0, 0, 0,
   0, pbCtrl.Handle.ToInt64, 0)    
    Dim IniTime As Long = GetTickCount() 
    While GetTickCount() < (IniTime + 1000)
        Application.DoEvents()
    End While    
    Dim OKAnswer As Boolean = False
    For xretries As Integer = 1 To 10
            I ll give you Only 10 tries to connect, otherwise I AM LEAVING MICROSOFT!
          OKAnswer = SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, VideoSource, 0)
          If OKAnswer Then
              Exit For
          End If    
    Next    
    If okanswer Then
          SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
          SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0)
          SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0)
          SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, pbCtrl.Width, pbCtrl.Height, SWP_NOMOVE Or SWP_NOZORDER)    
    Else
          DestroyWindow(hWnd)    
    End If    
End Sub

我也有同样的问题。 确保您在不再需要网络摄像头时 打电话给 Cap Driver Disconnect 。 请注意, 我使用Logitech C110, 但我想这在您的情况中也应该有效 。

在此寻找“ WM_CAP_ DRIVER_CONNECT” 和“ Video setup” 对话框弹出错误的解决方案 。

解决之道:

这是一个驱动程序问题。 使用 OEM s 驱动程序, 因为通用微软驱动程序不为您的相机工作 。

使用 www.astra32.com 查找 USB 相机设备信息: 制造商或型号; 然后为正确的驱动人谷歌 。

祝你好运!





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签