tags:

views:

252

answers:

4

It is quite tricky because I wanna to take the result as a sign for later process. If a window flashes, it would be weird to user.

+1  A: 

(This is not an answer, just refreshing the question and adding some details:)

Suppose you need to open a video capture driver (webcam) with code like this (delphi, but easy understandable):

result:= SendMessage(hCapWnd, WM_CAP_DRIVER_CONNECT, FDriverNo, 0);

It works fine, except when camera/webcam is busy (opened by another application, for example moviemaker). Then the capture driver suddenly shows a "select video source" window that blocks your application (but not moviemaker, which keeps recording). SendMessage function becomes modal and will not return until undesired window is closed.

Is there a way to detect if a capture driver is busy with another application before connecting to it?

Thanks

oscar
nobody else for this question?
oscar
A: 

I wonder if sending a broadcast message could do. I mean, suppose you send a VFW info request message to all windows in system. Then, all windows actually doing VFW processing will answer their status info and you will know which of them are doing video processing; some kind of shouting "anybody here...?"

But it looks like brute force, or even hacking. May be I'll test it... may be not. I am sure there must be a smarter way to know if a video capture driver is busy with another application.

(btw... anybody here?)

oscar
A: 

Dear sand of the desert, i can hear you say you don't like the broadcasting way. I think it too, it sounds too agressive, for example it can collide with windows that don't expect to receive multimedia messages from an unknown app, at a random moment, out of their possible internal synchronization.

And you have to send message bursts for each video capture driver installed, multiplied by the number of opened handle windows in the system... Looks so heavy, slow, risky, stressing, a SO AWFUL way! Yessssss.... I agree with you, my precioussss....

oscar
A: 

I was afraid it would happen.

First I enumerated all opened windows in system, then executed this instruction for each HWND, which just asks for driver information (pascal syntax):

SendMessage(h, WM_CAP_DRIVER_GET_NAME, length(driver)*sizeof(char), LPARAM(PChar(driver))

According to Msdn help, WM_CAP_DRIVER_GET_NAME results are:

"Returns TRUE if successful or FALSE if the capture window is not connected to a capture driver"

(Bold is mine). So it appears a good way to know:

1-If the window is capturing. So it is applyable to ALL windows, don't matter if they are capturing or not.
2-And if so, it tells you which driver is using.

However, after first test round, the results were:
- Task Manager (it was running) crashed and closed
- Explorer crashed and closed (reopened again automatically)
- Belkin Wireless monitor (my pc's WiFi driver) crashed and closed
- Eset Nod32 antivirus crashed, did not closed

The first conclussion can be that this is a bad way to locate which applications are capturing video in a system. But I must ensure to dismiss the possibility of a bug.

I'll keep reporting.

oscar
Haha! The reason is quit clear. Message is defined like this:WM_CAP_DRIVER_GET_NAME= (WM_USER+12);OMG, each app will translate a WM_USER+12 message in a rainbow of different ways!!!
oscar