推荐文章

c#去除字符串中的空格,回车,换行符,制表符

c#去除字符串中的空格,回车,换行符,制表符

c#去除字符串中的空格,回车,换行符,制表符
C#监控程序启动和关闭

C#监控程序启动和关闭

C#监控程序启动和关闭using System;using System.Collections.Generic;using System.Text;using System.Diagnostics;using System.Threading;namespace ProcessListener{ class Program { static void Main(stri
C#操作USB口的摄像头

C#操作USB口的摄像头

private const uint BM_CLICK = 0xF5; 鼠标点击的消息,对于各种消息的数值,查API手册,也可用VS2010自带的SPY++ [DllImpt("user32.dll", EntryPoint = "SendMessage", SetLastErr = true, Set = Set.Auto)]private static extern int SendMe
C# FTP操作

C# FTP操作

C# FTP操作
C#文件监控对象FileSystemWatcher

C#文件监控对象FileSystemWatcher

使用C#文件监控对象FileSystemWatcher对文件夹下的删除、修改、新增

C#操作USB口的摄像头

日期:2018-07-04 点击:2258 来源:PB2.CN

private const uint BM_CLICK = 0xF5; //鼠标点击的消息,对于各种消息的数值,查API手册,也可用VS2010自带的SPY++    

[DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hwnd, uint wMsg, IntPtr wParam, int lParam);

//开个线程准备关闭对话框
 System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(closevideoprompt));
            th.Start();
//线程中关闭对话框的函数
 private void closevideoprompt()
        {
            while (true)
            {
                System.Threading.Thread.Sleep(100);
                IntPtr hWnd = FindWindow(null, "视频源");
                //this.textBox1.Text = hWnd.ToString() + "!";
                //ShowWindow(hWnd, SW_RESTORE); //将窗口还原
                //SetForegroundWindow(hWnd); //如果没有ShowWindow,此方法不能设置最小化的窗口
                if (hWnd != IntPtr.Zero)
                {
                    IntPtr hwndSure = FindWindowEx(hWnd, (IntPtr)0, "Button", "确定"); //获取确定按钮的句柄                
                    SendMessage(hwndSure, BM_CLICK, (IntPtr)0, 0); //发送单击消息           
                }
            }
        }
//6次不成功就算了
          int i = 0 , j = 0;
            while (i != 1)
            {
                i = SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0);
                System.Threading.Thread.Sleep(100);
                j++;
                if (j > 6) { MessageBox.Show("请确认视频连接正常!"); th.Abort(); return; }
            }
勉强算解决了这个问题。就是开视频时用户还能看到视频源对话框一闪而过


这篇文档对您是否有帮助?

c#去除字符串中的空格,回车,换行符,制表符

c#去除字符串中的空格,回车,换行符,制表符

c#去除字符串中的空格,回车,换行符,制表符
C#监控程序启动和关闭

C#监控程序启动和关闭

C#监控程序启动和关闭using System;using System.Collections.Generic;using System.Text;using System.Diagnostics;using System.Threading;namespace ProcessListener{ class Program { static void Main(stri
C#操作USB口的摄像头

C#操作USB口的摄像头

private const uint BM_CLICK = 0xF5; 鼠标点击的消息,对于各种消息的数值,查API手册,也可用VS2010自带的SPY++ [DllImpt("user32.dll", EntryPoint = "SendMessage", SetLastErr = true, Set = Set.Auto)]private static extern int SendMe
C# FTP操作

C# FTP操作

C# FTP操作
C#文件监控对象FileSystemWatcher

C#文件监控对象FileSystemWatcher

使用C#文件监控对象FileSystemWatcher对文件夹下的删除、修改、新增