私は同じ行に沿って作業していますが、C# で作業しています。
アプリケーションをシステムに登録する必要があります (RegisterHidNotification() 関数を見てください)。私の場合は次のようになります。
void RegisterHidNotification() //Register this application to recieve all USB device notices
{
BroadcastHeader dbi = new BroadcastHeader();
int size = Marshal.SizeOf(dbi);
dbi.Size = size;
dbi.Type = DeviceType.DeviceInterface;
**dbi.Classguid = GUID_DEVINTERFACE_USB_DEVICE**;
dbi.Name = 0;
IntPtr buffer = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr(dbi, buffer, true);
IntPtr r = RegisterDeviceNotification(this.Handle, buffer, (int)DeviceEvents.regWindowHandle);
if (r == IntPtr.Zero)
statusLabel.Text = GetLastError().ToString();
}`
関数の最も重要な部分は、太字で強調表示した (または少なくとも試みた) ビットです。定義:public Guid GUID_DEVINTERFACE_USB_DEVICE = new Guid("A5DCBF10-6530-11D2-901F-00C04FB951ED");
あなたのアプリケーションに適応できることを願っています。