?
Solved

Get list of WebCams in the system

Posted on 2005-02-24
6
Medium Priority
?
1,952 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:Imthiyaz_ph
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 1000 total points
ID: 13400994
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
 
LVL 6

Author Comment

by:Imthiyaz_ph
ID: 13401136
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
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 13401296
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:Imthiyaz_ph
ID: 13401887
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
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 13401917
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
 
LVL 6

Author Comment

by:Imthiyaz_ph
ID: 13402237
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

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question