Article View: borland.public.cppbuilder.nativeapi
Article #4456Re: Question about WM_DEVICECHANGE
From: Kris
Date: Thu, 26 Jan 2006 15:49
Date: Thu, 26 Jan 2006 15:49
79 lines
3393 bytes
3393 bytes
On Wed, 25 Jan 2006 11:23:43 -0800, "Remy Lebeau \(TeamB\)"
>So? You can filter those out before deciding to scan your devices.
Filtering DBT_DEVTYP_VOLUME info with the DBTF_MEDIA works great in
order to determine whether or not the event was generated by a media
change or by an actual device change.
Actual device :
DBT_DEVICEARRIVE/REMOVE::dbch_devicetype=2::DBTF_MEDIA=0
DBT_DEVICEARRIVE/REMOVE::dbch_devicetype=2::DBTF_MEDIA=0
Media in the device :
DBT_DEVICEARRIVE/REMOVE::dbch_devicetype=2::DBTF_MEDIA=1
DBT_DEVICEARRIVE/REMOVE::dbch_devicetype=2::DBTF_MEDIA=1
However, I was wondering if it was also possible to filter on device
class basis (e.g. GUID_DEVINTERFACE_CDROM). I've tried various
combinations with the RegisterDeviceNotification() but am unable
accomplish this behaviour.
Any hints on this are welcome...
void __fastcall TMainForm::WndProc(TMessage& Message)
{
if (Message.Msg==WM_DEVICECHANGE)
{
if((Message.WParam==DBT_DEVICEARRIVAL)||
(Message.WParam==DBT_DEVICEREMOVECOMPLETE))
{
PDEV_BROADCAST_HDR pDBHdr=(PDEV_BROADCAST_HDR)Message.LParam;
PDEV_BROADCAST_VOLUME lpdbv=(PDEV_BROADCAST_VOLUME)Message.LParam;
DebugText("DBT_DEVICEARRIVE/REMOVE::dbch_devicetype=%X::DBTF_MEDIA=%X",
pDBHdr->dbch_devicetype,
lpdbv->dbcv_flags&DBTF_MEDIA
);
if (!lpdbv->dbcv_flags&DBTF_MEDIA)
{
DebugText(">> Refresh Device Grid");
}
}
}
else
{
TForm::WndProc(Message);
}
}
I tried several varation on this code :
void TMainForm::RegisterForDeviceNotification(void)
{
HDEVNOTIFY hDevNotify;
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;
GUID InterfaceClassGuid=GUID_DEVINTERFACE_CDROM;
ZeroMemory(&NotificationFilter,sizeof(NotificationFilter));
NotificationFilter.dbcc_size=sizeof(DEV_BROADCAST_DEVICEINTERFACE);
NotificationFilter.dbcc_devicetype=DBT_DEVTYP_DEVICEINTERFACE;
NotificationFilter.dbcc_classguid=InterfaceClassGuid;
hDevNotify=RegisterDeviceNotification(
Application->Handle,
&NotificationFilter,
DEVICE_NOTIFY_WINDOW_HANDLE);
if(hDevNotify)
{
MainForm->DebugText("RegisterDeviceNotification(GUID_DEVINTERFACE_CDROM)
: OK");
}
else
{
MainForm->DebugText("RegisterDeviceNotification
(GUID_DEVINTERFACE_CDROM) : ERROR");
}
}
Technical Details
Message-ID:
<nnrht151t3irpu8kkjp8cv0no27dckn5sh@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news2.volia.net!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!newsfeed.icl.net!newsfeed.fjserv.net!nntp.theplanet.net!inewsm1.nntp.theplanet.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<3qbft19f0602l0f1m44t2uhiuio593trh1@4ax.com> <43d7cf9f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,72e517fafc72a733 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Kris <x.y@xyz.xx> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Question about WM_DEVICECHANGE Date: Thu, 26 Jan 2006 16:49:34 +0100 Message-ID: <nnrht151t3irpu8kkjp8cv0no27dckn5sh@4ax.com> References: <3qbft19f0602l0f1m44t2uhiuio593trh1@4ax.com> <43d7cf9f$1@newsgroups.borland.com> X-Newsreader: Forte Free Agent 3.1/32.783 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.11.247.137 X-Trace: newsgroups.borland.com 1138290385 81.11.247.137 (26 Jan 2006 07:46:25 -0700) Lines: 79 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news2.volia.net!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!newsfeed.icl.net!newsfeed.fjserv.net!nntp.theplanet.net!inewsm1.nntp.theplanet.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail