且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拔出&插入USB webCame

更新时间:2023-02-08 17:48:34

您必须使用..正确的WebCam Driver dll文件,并在项目中使用该dll ..并使用该dll的方法.


hi I''m trying to reset my USB web-came using c# code,and I googled a lot of articles but didn''t get any useful solution

here''s my code:

System.Management.ObjectQuery objectQuery = new System.Management.ObjectQuery("select * from CIM_LogicalDevice ");
            
            // search and get the list
            System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher(objectQuery);
            System.Management.ManagementObjectCollection list = searcher.Get();
           
            // step through the list of devices
            label1.Text = list.Count.ToString();
                        
            foreach (System.Management.ManagementObject item in list)
            {
                listBox1.Items.Add(item.GetText(TextFormat.Mof));
                if (item.GetPropertyValue("caption").ToString().Contains("USB PC Camera"))
                {
                   
                    item.InvokeMethod("Reset", null);
                }
            }


it always give me an error when it get to the part item.InvokeMethod("Reset", null);
it says: This method is not implemented in any class
please any help
thank you

You Have to use .. Proper WebCam Driver dll file and use that dll in your project .. and consume that dll''s methods.