Home > OS >  How about U disk under Windows pop up (not pull) news
How about U disk under Windows pop up (not pull) news

Time:10-03

Recently met a problem - implemented using Qt U disk under Windows pop up, insert and pull out the surveillance, the essence of which is for Windows, before there is no relevant processing experience, so a search, and found the following solution, but can only listen to U insertion, pull out events, pop-up of U disk (U disk drive right | | pop-up) unable to listen to:

 bool Widget: : nativeEvent (const QByteArray & amp; EventType, void * message, long * result) 
{
//processing Windows message
MSG * MSG=(MSG *) message;

Int msgType=MSG - & gt; The message;
If (msgType==WM_DEVICECHANGE)//Windows device message
{
PDEV_BROADCAST_HDR LPDB=(PDEV_BROADCAST_HDR) MSG - & gt; LParam;
The switch (MSG - & gt; WParam)
{
Case DBT_DEVICEARRIVAL:
If (LPDB - & gt; Dbch_devicetype==DBT_DEVTYP_VOLUME)//logical volume
{
PDEV_BROADCAST_VOLUME LPDBV=(PDEV_BROADCAST_VOLUME LPDB);
If (LPDBV - & gt; Dbcv_flags==0)
{
QDebug () & lt; <"USB_ equipment physical insert";
}
}
break;
Case DBT_DEVICEREMOVECOMPLETE:
If (LPDB - & gt; Dbch_devicetype==DBT_DEVTYP_VOLUME)//logical volume
{
PDEV_BROADCAST_VOLUME LPDBV=(PDEV_BROADCAST_VOLUME LPDB);
If (LPDBV - & gt; Dbcv_flags==0)
{
QDebug () & lt; <"USB_ equipment physical pull out";
}
}
break;
}
}
return false;
}

The MSG - & gt; WParam message parameter of other types were tested respectively, and no one is used to mark "U disk pop-up" news events, parameter types listed below:

 
DBT_DEVICEREMOVEPENDING
DBT_CONFIGCHANGECANCELED
DBT_CUSTOMEVENT
DBT_DEVICEQUERYREMOVE
DBT_DEVICEQUERYREMOVEFAILED
DBT_DEVNODES_CHANGED
DBT_QUERYCHANGECONFIG
DBT_USERDEFINED

In this for help related processing experience or information to provide solution or plan, thank you!

CodePudding user response:

Process Monitor real-time Monitor file system and registry, Process, thread and DLL activities, http://www.microsoft.com/china/technet/sysinternals/utilities/processmonitor.mspx

WinAPIOverride http://jacquelin.potier.free.fr/winapioverride32/

CodePudding user response:

Still can try Spy++ monitor Windows messages,

CodePudding user response:

For not familiar with Windows programming, search for the problem of target is broad, and looking for a few days didn't got a clue...

CodePudding user response:

Didn't find the corresponding pop-up messages "U disk", only to see which U disk by means of regular polling ejection, in Microsoft's online check to a function on the MSDN:
https://msdn.microsoft.com/en-us/library/ff539806 (v=versus 85). Aspx

CM_Request_Device_Eject function

The CM_Request_Device_Eject function prepares a local device instance for safe removal, if The device is removable. If The device can be physically ejected, it will be.
Syntax
C + +

CMAPI
CONFIGRET
WINAPI CM_Request_Device_Eject (
_In_ DEVINST dnDevInst,
_Out_opt_ PPNP_VETO_TYPE pVetoType,
_Out_opt_ LPTSTR pszVetoName,
_In_ ULONG ulNameLength,
_In_ ULONG ulFlags
);

Use this function, temporarily use value U disk pop-up "polling" way, I will again behind if lucky enough to find the enclosed...

CodePudding user response:

The building Lord, this problem you solved? I now also in doing this, and could not find the corresponding solution, please teach

CodePudding user response:

reference 5 floor u012999850 reply:
the building Lord, this problem you solved? I am currently doing this thing, also didn't find the corresponding solution, please teach

Hello, still not solve! Don't know how to do monitoring users jinshan/360 is "the right keyboard operator | pop-up" operation, if you later find relevant solutions, please attached to the post office, thank you!
  • Related