Get list of WebCams in the system

Hi Experts

How can I get the list of webcams or the video sources installed in the system. I tried capGetDriverDescription, but its only giving me "Microsoft WDM Image Capture Driver". I actually need the list of cams, like in VideoGrabber component.

Imthiyaz
LVL 6
Imthiyaz_phAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee_NoverCommented:
with directshow you can use the ICreateDevEnum interface ...
this is taken from DSPack - www.progdigy.com (which I suggest you use :))

  procedure TSysDevEnum.GetCat(catlist: TList; CatGUID: TGUID);
  var
    SysDevEnum : ICreateDevEnum;
    EnumCat    : IEnumMoniker;
    Moniker    : IMoniker;
    Fetched    : ULONG;
    PropBag    : IPropertyBag;
    Name       : olevariant;
    hr         : HRESULT;
    i          : integer;
  begin
    if catList.Count > 0 then
      for i := 0 to (catList.Count - 1) do if assigned(catList.Items[i]) then Dispose(catList.Items[i]);
    catList.Clear;
    CocreateInstance(CLSID_SystemDeviceEnum, nil, CLSCTX_INPROC, IID_ICreateDevEnum, SysDevEnum);
    hr := SysDevEnum.CreateClassEnumerator(CatGUID, EnumCat, 0);
    if (hr = S_OK) then
    begin
      while(EnumCat.Next(1, Moniker, @Fetched) = S_OK) do
        begin
          Moniker.BindToStorage(nil, nil, IID_IPropertyBag, PropBag);
          new(ACategory);
          PropBag.Read('FriendlyName', Name, nil);
          ACategory^.FriendlyName := Name;
          if (PropBag.Read('CLSID',Name,nil) = S_OK) then
            ACategory^.CLSID := StringToGUID(Name)
          else
            ACategory^.CLSID := GUID_NULL;
          catlist.Add(ACategory);
          PropBag := nil;
          Moniker := nil;
        end;
    end;
    EnumCat :=nil;
    SysDevEnum :=nil;
  end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Imthiyaz_phAuthor Commented:
Thankyou for replying, Lee.

I have used windows AVICap api to capture images, instead of DirectShow to reduce dependencies and the size of the executable. Is there any way to get the list without using DirectShow ?
0
Lee_NoverCommented:
humz .. I don't think I could do that with vfw ..
you did an enum like:

LIndex:=0;
while capGetDriverDescription(LIndex, buf, bufLen, nil, 0) do
begin
  Inc(LIndex);
  List.Add(string(buf));
end;


I think the problem is in the drivers
cap* functions don't support WDM devices .. instead there's a vfw-wdm mapper that handles this

anyway I chose DS over vfw for the possibilites it ofered compared to vfw .. easines of implementation, practicaly unlimited options :)

vfw is here only because of compatibility with windows 3.x apps !!! windows 95 already included first DirectShow impls. under the name ActiveMovie
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Imthiyaz_phAuthor Commented:
Thankyou Lee. I finally decided to use Directshow itself using DSPack. Using your code, i was able get the list of cams, but they cannot be used with vfw apis, as those api require the index of the driver and in my case there is only one driver.

I downloaded DSPack and they are using DirectX 9. We have Dx9 installed on most of our systems. Will there be compatiblity issues when running the app in a system with Dx8 or Dx7 ?
0
Lee_NoverCommented:
I don't think so .. it depends which interfaces you're using
if you want VMR9 you'll need DX9 .. otherwise it shouldn't be a problem
the capture and other related interfaces were already in activemovie
0
Imthiyaz_phAuthor Commented:
I tested a demo app in Dx9 and Dx8, its working fine, but it failed in an old machine with Win98 + Dx6. Since most of our clients will be using Win2k/XP, I think we might not have any compatibility issues. One again, thank you for the support.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.