I'm trying to detect the event when a FireWire cable is plugged into the FireWire port of the PC withing MFC C++ app. I would also like to trigger this even myself as the FireWire connections drops and never is rediscovered withing unplugging the cable and plugging it back in.
Anyone have any experience trying to programmaticaly simulate a unplug-replug event?
You can register yourself to receive device arrival messages. See the help for RegisterDeviceNotification to find an example on how to register yourself.
You can trigger a bus reset notification on the firewire bus, but I don't know if you can do this from user mode, without the help of a kernel mode module.
Related
I have developed an application in C++ that runs on Windows 7, 8.x and 10. I would like to use a Bluetooth remote shutter to control the application.
The remote shutter seems to be a HID device that sends keypresses to Windows. The default behavior of those keypresses is Volume Up, Volume Down, Play/Pause, Next and Previous.
While I can detect those keypresses from my application and act on them, I have not managed to disable Windows acting on them. E. g. currently, when someone presses the Volume Up key on the remote shutter, two things happen:
Whatever I tell my application to do on that keypress
Also, volume goes up on Windows
How can I tell Windows not to act on those keypresses for this particular device?
Thank you
I have not tried it but i think it may be possible by disabling the Human Interface Device Access Service on Windows.
There may be some side effects along with that like for example:
If the service is stopped or disable, the buttons on USB keyboards will not function (i.e., back, forward, volume up, down, previous track, next track), nor will the volume buttons on USB speakers.
but you can still try :)
here is how to disable it
I am attempting to detect when my TV is connected to my laptop via HDMI cable. I am using the WinAPI function RegisterDeviceNotification() to handle device messages.
When I connect my TV to my laptop (via HDMI cable) I never receive a WM_DEVICE_ARRIVAL message, only 3 WM_DEVICE_CHANGE events. Is this normal?
I really need the WM_DEVICE_ARRIVAL event because the lParam(or wParam, I forget) contains a structure that tells me the type of device connected and the device name whereas, afaik, the WM_DEVICE_CHANGE event does not contain this structure.
If its normal to not receive a WM_DEVICE_ARRIVAL message upon HDMI port insertion, what other method could I use to determine the devices name and type when its connected?
My only idea is: list all devices upon application startup, upon device connection react to the WM_DEVICE_CHANGE event and see if the list of devices has increased.
You could poll GetSystemMetrics(SM_CMONITORS) or EnumDisplayMonitors.
The WM_SETTINGCHANGE message is (usually) sent by applications and services which change system metrics, including the desktop resolution (which changes when HDMI is plugged if the desktop is extended, it wouldn't for mirroring). You could use this to trigger the above polling, instead of relying solely on a timer.
Once my embedded device is connected to USB port of my PC, it should trigger an exe as an event. How can I achieve this??
Should I create a service to keep monitoring the USB connector bus or is there any default API's available in Windows to achieve this??
thanks.
A simple exe which is started on connect is not possible. But you can write a service or user mode application which listens for device arrival events. WM_DEVICECHANGE is sent to all (registered) applications with a device interface guid which represents which device is plugged in. You can then use this id with the setupapi to see if its your device.
On receiving that event, you can then start your executable.
Depending on your version of Windows it might be possible with a workaround using a AutoRun.inf file in the root folder of a USB drive. For security reasons this is by default turned off, and in Windows 7 not allowed at all.
To achieve the same effect in a more robust way, you need to create a service that monitors whether your device is connected or not (e.g. iTunesHelper that monitors for connected Apple devices).
The easiest solution is probably a trivial UMDF driver. That's basically a small COM component called when your device is connected.
I want to be notified when a microphone jack is plugged in. What is the event fired by the OS(particularly Vista)
The audio panel shows no recording device active if no mic plugged in(vista). This never happened in XP.
Also if my microphone had a "advance control" for eg Bass Boost, Mic Boost(AGC) etc, how can I get the mixer control for the same to control it.
I'm using MFC for development.
Thanks
I believe that you want to implement IMMNotificationClient and handle the OnDeviceAdded event.
If you want the various controls in Vista, you're better off using the Device Topology API to get the controls (IAudioLoudness, etc.) Otherwise, you need to enumerate the mixer device IDs & ask them for their endpoint IDs, then compare the endpoint ID to find the real device you're interested in.
Regarding the Windows platform, is their an event I can look for to tell when a USB drive or any type of portable media us plugged in?
You won't get such notifications without first registering for them. Use RegisterDeviceNotification() to do that.
After you have registered your window to receive such notifications, handle the WM_DEVICECHANGE message.