#include <windows.h>
#include <stdio.h>
#include <iostream.h>
#include "vfw.h"
#pragma comment( lib, "vfw32.lib" )
void main()
{
char strDeviceVersion[80]; //設(shè)備版本信息
char strDeviceAndVersion[160]; //設(shè)備名和版本信息
int nIndex;
int nDriverCount = 0; //支持的設(shè)備驅(qū)動程序個數(shù)
for(nIndex=0; nIndex <9; nIndex++)
{
if(capGetDriverDescription(nIndex,(LPSTR)strDeviceAndVersion,sizeof(strDeviceAndVersion),(LPSTR)strDeviceVersion,sizeof(strDeviceVersion)))
{
strcat(strDeviceAndVersion,",");
strcat(strDeviceAndVersion,strDeviceVersion);
nDriverCount++; //得到vfw設(shè)備信息及連的設(shè)備數(shù)量
}
else
break;
}
if (nDriverCount==0)
cout <<"沒有攝像頭"<<endl;
else
cout <<"有攝像頭"<<endl;
}