Quantcast
Viewing all articles
Browse latest Browse all 5361

USB Event

Hello Everybody,

I am attempting to set up events for a change in the USB state. The event fires, but there is no change in the parameters. lParam and wParam are always the same value regardless of an insertion or removal of a usb device. Any suggestions?

 

Here is the Windows API: 

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363480(v=vs.85).aspx

 

#include "windows.h"
#include "Dbt.h"
#include "toolbox.h"
#include <cvirte.h> /* Initialize CVI libraries */
#include <userint.h>
#include <libsupp.h>

int main (int argc, char *argv[]) { if (InitCVIRTE (0, argv, 0) == 0) { return -1; } if ((panelHandle = LoadPanel (0, "PANEL.uir", PANEL)) <= 0) { return -1; } InstallWinMsgCallback (panelHandle, WM_DEVICECHANGE , UsbCallback, VAL_MODE_INTERCEPT, NULL, &postingHandle); RegisterWinMsgCallback(UsbCallback, 0, NULL, 0, &id, 1); /* display the panel and run the UI */ DisplayPanel (panelHandle); RunUserInterface (); RemoveWinMsgCallback(panelHandle, WM_DEVICECHANGE); /* free resources and return */ DiscardPanel (panelHandle); CloseCVIRTE (); return 0; } int CVICALLBACK UsbCallback (int panelHandle, int message, unsigned int* wParam, unsigned int* lParam, void* callbackData) { struct _DEV_BROADCAST_HEADER *DeviceHeader = (struct _DEV_BROADCAST_HEADER *)lParam; unsigned int DeviceType = DeviceHeader->dbcd_devicetype; switch (*wParam) { case DBT_DEVICEARRIVAL:
break; } /* switch */ return 0; } /* UsbCallback */

Viewing all articles
Browse latest Browse all 5361

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>