如何在计算机上获取所有可用的网络摄像头驱动程序? 我想在组合框中显示驱动程序。
答案 0 :(得分:7)
要枚举网络摄像头,您可以使用System Device Enumerator,传递将获得所有视频捕获设备的CLSID_VideoInputDeviceCategory
GUID。
试试这个样本
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows,
ActiveX,
DirectShow9,
ComObj;
procedure EnumerateVideoInputDevices;
const
IID_IPropertyBag : TGUID = '{55272A00-42CB-11CE-8135-00AA004BB851}';
var
LDevEnum : ICreateDevEnum;
ppEnumMoniker : IEnumMoniker;
pceltFetched : ULONG;
Moniker : IMoniker;
PropBag : IPropertyBag;
pvar : olevariant;
hr : HRESULT;
i : integer;
begin
CocreateInstance(CLSID_SystemDeviceEnum, nil, CLSCTX_INPROC, IID_ICreateDevEnum, LDevEnum);
hr := LDevEnum.CreateClassEnumerator(CLSID_VideoInputDeviceCategory, ppEnumMoniker, 0);
if (hr = S_OK) then
begin
while(ppEnumMoniker.Next(1, Moniker, @pceltFetched) = S_OK) do
begin
Moniker.BindToStorage(nil, nil, IID_IPropertyBag, PropBag);
if PropBag.Read('Description', pvar, nil) = S_OK then
Writeln(Format('Description %s',[String(pvar)]));
if PropBag.Read('FriendlyName', pvar, nil) = S_OK then
Writeln(Format('Friendly Name %s',[String(pvar)]));
if PropBag.Read('DevicePath', pvar, nil) = S_OK then
Writeln(Format('Device Path %s',[String(pvar)]));
if PropBag.Read('CLSID', pvar, nil) = S_OK then
Writeln(Format('CLSID %s',[String(pvar)]));
PropBag := nil;
Moniker := nil;
end;
end;
ppEnumMoniker :=nil;
LDevEnum :=nil;
end;
begin
try
CoInitialize(nil);
try
EnumerateVideoInputDevices;
finally
CoUninitialize;
end;
except
on E:EOleException do
Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));
on E:Exception do
Writeln(E.Classname, ':', E.Message);
end;
Writeln('Press Enter to exit');
Readln;
end.