Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Get list of WebCams in the system

Posted on 2005-02-24
6
Medium Priority
?
1,974 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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

581 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