DeviceChage???

I wanna detect flash memory stic when it is plugged and removed by using DeviceChage Method.
In fact, the program i made worked before i did something..
but, now it doesn't work anymore, so i debuged lots of time.
i will post the func() blow.
I can't find anything wrong. but "wparam" always says 7 which is defined
as "DBT_DEVINSTENUMERATED" in Dbt.h.

here is define of Dbt.h
(I need this one)#define DBT_DEVICEARRIVAL 0x8000 // system detected a new device

#define DBT_DEVICEQUERYREMOVE 0x8001 // wants to remove, may fail
#define DBT_DEVICEQUERYREMOVEFAILED 0x8002 // removal aborted
#define DBT_DEVICEREMOVEPENDING 0x8003 // about to remove, still avail.
#define DBT_DEVICEREMOVECOMPLETE 0x8004 // device is gone
#define DBT_DEVICETYPESPECIFIC 0x8005 // type specific event

#if(WINVER >= 0x040A)
#define DBT_CUSTOMEVENT 0x8006 // user-defined event
#endif /* WINVER >= 0x040A */

#if(WINVER >= _WIN32_WINNT_WIN7)
(but always i get this one)#define DBT_DEVINSTENUMERATED 0x8007 // system detected a new device
#define DBT_DEVINSTSTARTED 0x8008 // device installed and started
#define DBT_DEVINSTREMOVED 0x8009 // device removed from system
#define DBT_DEVINSTPROPERTYCHANGED 0x800A // a property on the device changed
#endif /* WINVER >= _WIN32_WINNT_WIN7 */


here's source code :
LRESULT CTooletDlg::OnDeviceChange( WPARAM wParam ,LPARAM lParam)
{
PDEV_BROADCAST_HDR pHdr = ( PDEV_BROADCAST_HDR ) lParam;
CString strTargetDriveName = _T("");

switch(wParam )
{
case DBT_DEVICEARRIVAL:
.. do something
break;
case DBT_DEVICEREMOVECOMPLETE:
.. do something
break;
......
}
}

anyone has any ideas??
Thank you in advance. :)
I see that both DBT_DEVICEARRIVAL and DBT_DEVINSTENUMERATED have the same comment : system detected a new device

Could this be a new, improved method for the same purpose??
Yes, you are right. I tried to use that DBT_DEVINSTENUMERATED , but i got an error saying "not defined.....". And also the program works on Debug mode, but doesn't work on Release mode.
I heard that the problem would probably be from Memory management. It's hard for me to solve it.
I am working on it, plz give me any idea~!.
Well, asking the next obvious question, have you defined WINVER as required?

DBT_DEVINSTENUMERATED is for Windows 7 and newer.

Andy

P.S. Do yoi know if your code (still) runs OK on Vista or XP?
Topic archived. No new replies allowed.