VC 检测计算机是否安装有摄像头

#include <windows.h>
#include <stdio.h>
#include <iostream.h>
#include "vfw.h"
#pragma comment( lib, "vfw32.lib" )

void main()
{
   
    char strDeviceVersion[80];    //设备版本信息
    char strDeviceAndVersion[160];  //设备名和版本信息
    int nIndex;
    int nDriverCount = 0;                //支持的设备驱动程序个数
   
   
    for(nIndex=0; nIndex <9; nIndex++) 
    { 
        if(capGetDriverDescription(nIndex,(LPSTR)strDeviceAndVersion,sizeof(strDeviceAndVersion),(LPSTR)strDeviceVersion,sizeof(strDeviceVersion))) 
        { 
            strcat(strDeviceAndVersion,","); 
            strcat(strDeviceAndVersion,strDeviceVersion); 
            nDriverCount++;                  //得到vfw设备信息及连的设备数量
        } 
        else 
            break; 
    } 
    if (nDriverCount==0)
        cout <<"没有摄像头"<<endl; 
    else
        cout <<"有摄像头"<<endl; 
}

猜你喜欢

转载自www.cnblogs.com/daggex/p/10204055.html
vc