Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 16044

SHChangeNotify for adding and removing disks

$
0
0
Hi VB-nerds,

I hope you can help: I have an application connecting to an ftp-site and adding that connection as local disk. I use rclone for that. As the disk not shows up automatically in Windows Explorer I use SHChangeNotify to do the job for me:

Private Declare Function SHChangeNotify Lib "Shell32.dll" (ByVal wEventID As Long, ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long) As Long
Private Const SHCNF_FLUSH As Long = &H1000
Private Const SHCNE_DRIVEADD As Long = &H100
Private Const SHCNE_DRIVEREMOVED As Long = &H80
Private Const SHCNF_PATH As Long = 5

This code to add the drive to Explorer works perfectly:

Call SHChangeNotify(0, SHCNF_FLUSH, 0, 0)
Call SHChangeNotify(SHCNE_DRIVEADD, SHCNF_PATH, strptr("K:"), 0)

But this one doesn't (I need this when I unmount the disk):

Call SHChangeNotify(0, SHCNF_FLUSH, 0, 0)
Call SHChangeNotify(SHCNE_DRIVEREMOVED, SHCNF_PATH, strptr("K:"), 0)

Any idea what I am doing wrong?

Viewing all articles
Browse latest Browse all 16044

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>