WM_QUERYCANCELAUTOPLAY est entier = API("USER32", "RegisterWindowMessageA", "QueryCancelAutoplay")
// Et on bloque la popup Windows d'insertion automatique (CD-ROM/DVD)
Evénement("DeviceNotification", FenEnExécution(), WM_QUERYCANCELAUTOPLAY)
// *********************************************************************
// La fonction WinDev fDétecteStockageAmovible étant trop limitée
// On gère nous-même l'insertion ou la suppression des devices amovibles
// *********************************************************************
FONCTION DeviceNotification(wMsg, wParam, lParam)
DEV_BROADCAST_HDR est structure
dbch_size est un entier sans signe sur 4 octets
dbch_devicetype est un entier sans signe sur 4 octets
dbch_reserved est un entier sans signe sur 4 octets
FIN
DEV_BROADCAST_VOLUME est structure
dbch_size est un entier sans signe sur 4 octets
dbch_devicetype est un entier sans signe sur 4 octets
dbch_reserved est un entier sans signe sur 4 octets
dbcv_unitmask est un entier sans signe sur 4 octets
dbcv_flags est un entier sans signe sur 2 octets
FIN
nRet est entier = 0
// On bloque la popup de notification d'insertion Windows
// qui demande ce qu'on veut faire du CD/DVD
SI wMsg = WM_QUERYCANCELAUTOPLAY ALORS
nRet = 1
SINON // On gère l'insertion et la suppression d'un device
SI wParam = DBT_DEVICEREMOVECOMPLETE OU wParam = DBT_DEVICEARRIVAL ALORS
SI lParam ALORS
stDevHDR est DEV_BROADCAST_HDR
Transfert(&stDevHDR, lParam, Dimension(stDevHDR))
SI stDevHDR:dbch_devicetype = DBT_DEVTYP_VOLUME ALORS
stDevVOL est DEV_BROADCAST_VOLUME
Transfert(&stDevVOL, lParam, Dimension(stDevVOL))
DoIt est entier = Faux
sDrive est chaîne = BFF_DEVICE_DRIVE(stDevVOL:dbcv_unitmask)
hTreeView est entier = BFF_GET_TV_HANDLE()
sFolderName est chaîne = BFF_GET_PATH()
// StockageAmovibleRetiré
// ----------------------
SI wParam = DBT_DEVICEREMOVECOMPLETE ALORS
SI Gauche(Majuscule(sFolderName), 1) = Majuscule(sDrive) ALORS
sFolderName = fRepEnCours()
// Efface le contenu de la table et la liste masquée
ClearFolderContent()
DoIt = UpdateRegistry(sFolderName)
FIN
// StockageAmovibleInséré
// ----------------------
SINON SI wParam = DBT_DEVICEARRIVAL
SI MsgBoxYesNo("Unité de stockage amovible", "Une nouvelle untié de stockage a été détectée." + RC + RC + "Souhaitez-vous accèder au média " + sDrive + ":\ ?", UseIconDevices) = Oui ALORS
sFolderName = sDrive + ":\"
// Efface le contenu de la table et la liste masquée
ClearFolderContent()
DoIt = UpdateRegistry(sFolderName)
FIN
FIN
// On masque le Treeview
ShowWindow(hTreeView, SW_HIDE)
// On réinitialise le TreeView et on se replace sur le folder actif
InitTreeViewFolder(sFolderName)
// On réaffiche le Treeview
ShowWindow(hTreeView, SW_SHOW)
// On met à jour la table
SI DoIt ALORS UpdateTable(MakeLong(0, Bff_SelChange))
FIN
FIN
FIN
FIN
RENVOYER nRet
Cette contribution était de : http://old.wdforge.org/newbb/viewtopic.php?forum=18&topic_id=5500&post_id=22622