Click here to Skip to main content
15,891,704 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: REQ : Question with message box. Pin
David Crow15-Oct-05 16:15
David Crow15-Oct-05 16:15 
AnswerRe: REQ : Question with message box. Pin
Jack Puppy15-Oct-05 16:19
Jack Puppy15-Oct-05 16:19 
GeneralRe: REQ : Question with message box. Pin
zerofire15-Oct-05 16:27
zerofire15-Oct-05 16:27 
AnswerRe: REQ : Question with message box. Pin
daojinliu16-Oct-05 0:52
daojinliu16-Oct-05 0:52 
QuestionHow to delete a class? Pin
kevincwong15-Oct-05 15:37
kevincwong15-Oct-05 15:37 
AnswerRe: How to delete a class? Pin
daojinliu15-Oct-05 15:56
daojinliu15-Oct-05 15:56 
GeneralRe: How to delete a class? Pin
kevincwong15-Oct-05 16:45
kevincwong15-Oct-05 16:45 
QuestionEnumerate (list) USB Webcams Pin
Howard Anderson15-Oct-05 15:27
Howard Anderson15-Oct-05 15:27 
I need to be able to list webcams that are plugged in. I can use DeviceChange to tell when a webcam is plugged or unplugged and I am then using the function shown below to create a list of all video devices. This works for all "normal" webcam devices since they appear and disappear from the list when I call the function after they are plugged in or unplugged. Unfortunately, I also have an older webcam, Logitech "Quickcam", that is ALWAYS listed regardless of whether it is plugged in or not... That represents a pathological case. I need a way to determine if it is really plugged in WITHOUT disrupting it in case my software is currently using it. I have scoured all 5 device driver and USB books I know of, scoured MSDN, scoured the internet, tried LOTS of code including USBView which ALMOST provides the information but DISPLAYS A DIFFERENT NAME (not the "FriendlyName" I expected!) so I cannot correlate the information. Anyone know of a solution? (I think this is a REALLY tough problem... I will be unavailable for a couple of weeks but I really need to find a solution and will respond as soon as possible...)

VideoDeviceList *CMotionDetectDlg::GetVideoDeviceList()
{
static VideoDeviceList VideoList;


USES_CONVERSION;

UINT uIndex = 0;
HRESULT hr;
BOOL bCheck = FALSE;

//Clear all previous video list entries

for(int i = 0; i < NUMELMS(VideoList.videoMoniker); i++)
{
if(VideoList.videoMoniker[i]){
VideoList.videoMoniker[i]->Release();
VideoList.videoMoniker[i] = NULL;
}
}

VideoList.videoString.RemoveAll();
VideoList.numberOfDevices = 0;

// enumerate all video capture devices
ICreateDevEnum *pCreateDevEnum = 0;
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void**)&pCreateDevEnum);
if(hr != NOERROR)
{
MessageBox(NULL, "Error Creating Device Enumerator");
return NULL;
}

IEnumMoniker *pEm = 0;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
&pEm, 0);
if(hr != NOERROR)
{
CString message;
message = CString("No Video capture device was found.\r\n\r\n")
+ CString("Please plug in a webcam or other video capture device.");
//MessageBox(message, "Notice");

if(pEm)pEm->Release();

return NULL;
}

pEm->Reset();
ULONG cFetched;
IMoniker *pM;

while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK)
{
IPropertyBag *pBag=0;

hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
if(SUCCEEDED(hr))
{

//VARIANT vardes;
//vardes.vt = VT_BSTR;
//hr = pBag->Read(L"Description", &vardes, NULL);

VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL);
if(hr == NOERROR)
{
VideoList.videoString.InsertAt(uIndex, CString(W2T(var.bstrVal)));
SysFreeString(var.bstrVal);
VideoList.numberOfDevices++;

ASSERT(VideoList.videoMoniker[uIndex] == 0);
VideoList.videoMoniker[uIndex] = pM;
pM->AddRef();
}
pBag->Release();
}

pM->Release();
uIndex++;
}
pEm->Release();

return &VideoList;
}

THANKS!


Howard C. Anderson
HTTP://www.astroshow.com
HTTP://www.azcendant.com
AnswerRe: Enumerate (list) USB Webcams Pin
FlyingTinman19-Oct-05 16:09
FlyingTinman19-Oct-05 16:09 
GeneralRe: Enumerate (list) USB Webcams Pin
Howard Anderson10-Nov-05 4:31
Howard Anderson10-Nov-05 4:31 
QuestionMenu invokes dialog Pin
kevincwong15-Oct-05 12:52
kevincwong15-Oct-05 12:52 
AnswerRe: Menu invokes dialog Pin
Roger Allen15-Oct-05 13:46
Roger Allen15-Oct-05 13:46 
GeneralRe: Menu invokes dialog Pin
kevincwong15-Oct-05 14:00
kevincwong15-Oct-05 14:00 
GeneralRe: Menu invokes dialog Pin
kevincwong15-Oct-05 15:19
kevincwong15-Oct-05 15:19 
QuestionCBitmap Pin
fjlv200515-Oct-05 11:37
fjlv200515-Oct-05 11:37 
AnswerRe: CBitmap Pin
Prakash Nadar15-Oct-05 19:07
Prakash Nadar15-Oct-05 19:07 
GeneralRe: CBitmap Pin
fjlv200517-Oct-05 14:44
fjlv200517-Oct-05 14:44 
GeneralRe: CBitmap Pin
Prakash Nadar17-Oct-05 16:30
Prakash Nadar17-Oct-05 16:30 
QuestionTransparent CBitmapButton Pin
fjlv200515-Oct-05 7:27
fjlv200515-Oct-05 7:27 
Questiondbt.h Pin
karmendra_js15-Oct-05 5:33
karmendra_js15-Oct-05 5:33 
AnswerRe: dbt.h Pin
Prakash Nadar15-Oct-05 6:29
Prakash Nadar15-Oct-05 6:29 
QuestionDisable linker warnings Pin
leppie15-Oct-05 5:31
leppie15-Oct-05 5:31 
AnswerRe: Disable linker warnings Pin
Prakash Nadar15-Oct-05 19:13
Prakash Nadar15-Oct-05 19:13 
AnswerRe: Disable linker warnings Pin
ThatsAlok16-Oct-05 18:46
ThatsAlok16-Oct-05 18:46 
QuestionRe: Disable linker warnings Pin
leppie17-Oct-05 1:16
leppie17-Oct-05 1:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.