Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello,

I want to get the friendly names of all video capture devices in an array string. I've seen some examples to get them in a comboBox or a listBox, which I don't want to do. My prog refers to "Selecting a Capture Device"(msdn) is right. And I think it's the method, how to get the strings in an array in a while-loop under c++/win forms app, that matters. Altough I searched a lot in the net, I couldn't get useful informations that helps.

Could you please help?

My Codes:
C#
while (pClassEnum->Next(1, &pMoniker, &cFetched) == S_OK)
 {             
    hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
    if (FAILED(hr))
        {
            pMoniker->Release();
            return hr;  
        } 
    hr = pBag->Read(L"FriendlyName", &var, 0);

              if (SUCCEEDED(hr))
                {
 //String^ NAME = gcnew String(var.bstrVal);
 
// With only the line before, the friendly name can be gotten, but obviously only one because it's just a string. I've made a break point to see how the prog runs. And I saw the var.bstrVal has been built three times, that means the NAME I finally got is the last device name.

                    array <String^>^ NAME;

                    NAME[2] = gcnew String (var.bstrVal);// I have 3 webcams, I want their names to be saved in the array NAME[2].

                }
                VariantClear(&var);

        pBag->Release();
        pMoniker->Release();

  }

Selecting a Captur Device:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd377566(v=vs.85).aspx[^]
Posted
Updated 17-Oct-12 3:48am
v5
Comments
Sergey Alexandrovich Kryukov 1-May-13 0:26am    
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership. And the fact you even self-accepted some formally is just outrageous, a sure way for a ban. I hope you won't do it after this warning.

Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
—SA
christmars 1-May-13 4:56am    
Hi dear SA,

>Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your >CodeProject membership. And the fact you even self-accepted some formally is just outrageous, a sure way for a ban. I hope you won't do >it after this warning.

Thank you for your kind warning! I thought this is a website where we can freely think and discuss and talk about our own ideas about programing. When you say it is "outrageous" or "a sure way for ban". I'd like to say that all the questions I gave were acturally problems I faced by my work. Only after lots of searchs and tests I got "my" answer. This solves my problem. And I just thought they are helpful when somebody else also handles the same thing.
I would like to ask you, is there any "official set rules" or whatelse by programing? I think programers should think and prove their solutions and make innovations. That's also why codes are so fun. Because there are many ways to solve every one small task. So, if you see the problems in my answers, that points out "it's wrong", please post me and prove it. I'll be very glad to know about it and reject the solution and improve and share it for other friends here. I'll accept the truth, but not the "words"! Futher more, if I saw any better solutions or new right solutions under my questions. There's no doubt that I'll take them as the "solutions". But in fact it doesn't happen until now. I'm looking forward for it! :)



>Comment on any posts, reply to available comments, or use "Improve question" (above).
>Also, keep in mind that members only get notifications on the post sent in reply to there posts.
I konw where they are, thanks for that all the same!
You mean "their", don't you?

I love codeproject because it's a place full of ideas! And I hope we can freely dicuss here for any "questions"!

Best regards from Germany,
christmars
Sergey Alexandrovich Kryukov 1-May-13 16:57pm    
Please understand: anyone can put some question and answer it, even it has no value. Who would be interested in your internal problems and finding? Some did it intentionally on a regular basis to cheat on the points, were reported and then the accounts were cancelled. And when you accepted your "answers" formally, you praise yourself, but this acceptance is designed to accept that some advice by another member helped you. In no way I'm trying to think you did it on purpose, that's why I decided to warn you. Really, it's the best to avoid answering by yourself, to avoid abuse reports and down-voted.

"Add your solution here" is really designed for post indented to provide help in response to some question. If you don't answer your own question, it does not limit your ability to share some interesting solution which might be useful not just for you. Instead, you can publish a short Tips & Trick article; it it is interesting or useful, it would be quite appreciated. You could reference you original question there, if you want.

When I say "in reply to their posts" I don't mean just myself. When you use "Reply" or "Add comment" to any posts, the notification is sent to the person who put the post you are commenting, and also to upper-level posts up to the original one. When you put an answer, only the author of the question receives a notification. So, it's important to place comment in appropriate places, to take those notifications into account.

Thank you for understanding.

Cheers,
—SA
christmars 2-May-13 3:05am    
Alright, I see! No, I definitly have no intreast about CHEETING points! They mean nothing to me! I prefer knowleges. Please also understand. :)
Then I would take your advice above from now on.
If you could understand, what I did was, I clicked "I've solved it myself". Then it goes automatically to "Add your solution here". If we want to stop some boring ones who cheat points. Then this is also a stupid design ("I've solved it myself"), I have to say.
Thanks again!
Regards,
christmars
Sergey Alexandrovich Kryukov 2-May-13 9:25am    
Thank you for your note. First of all, I had absolutely no intent to accuse you in cheating and I'm sure about your good will. I was trying to convince authors of the site to improve the design (which I think is generally convenient and nicely readable) in certain points. Some changes are in progress right now...
—SA

PHP
$array=@(".\Business_Layer\Java\com\saba\client\contentinventory\great.java@@\main\1",".\Business_Layer\Java\com\saba\learningoffering\business\power.java@@\main\2",".\Business_Layer\Java\mil\army\dls\ajax\persist\strong.java@@\main\4",".\DB_Scripts\DefectFixes\cool.sql@@\main\1")
for ($i=0; $i -lt $array.length; $i++) {
$a = $array[$i].split("\")
$count= $a.Count
$Fname=  $a[$count - 3]
$Finalname = $Fname.split("@@")
$Finalname #list out all the $finalname everytime it goes through a loop 
}

This is my version of the script that I can make the file names come back
 
Share this answer
 
v2
Comments
christmars 18-Oct-12 7:17am    
Hi! Thank you! I'm not familiar with java. So could you please translate the codes into C? As I understand, you make an array to save the finalnames, and get values in a for-loop. But I really can't "see" your codes.
christmars 19-Oct-12 3:33am    
I got it myself, thanks all the same!
SoMad 6-Apr-13 1:14am    
Taken from the last post on this page: http://powershellcommunity.org/Forums/tabid/54/aft/8707/Default.aspx[^]

Soren Madsen
Use a StringList to realize that:
List <string^>^ LNAMES = gcnew List<string^>;
LNAMES->Add(gcnew String(var.bstrVal));
then the friendly names are added to your string list, and you can use them e.g. to show them on textboxes:
TextBox1->Text= LNAMES[0];
TextBox2->Text= LNAMES[1];
......
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900