Hi,
I have been using this code for some time to get the name of the currenty disk in the DVD-Drive.
VB Code:
Dim VI As VolumeInfo 'getVolumeInfo Private Type VolumeInfo Serial As Long VolumeName As String FileSystemName As String End Type Private Function GetVolumeInfo(Drive As String) As VolumeInfo Dim tmp As VolumeInfo tmp.VolumeName = Space(255) tmp.FileSystemName = Space(255) GetVolumeInformation Drive & ":\", tmp.VolumeName, 255, tmp.Serial, 0, 0, tmp.FileSystemName, 255 tmp.VolumeName = Trim(tmp.VolumeName) tmp.FileSystemName = Trim(tmp.FileSystemName) GetVolumeInfo = tmp End Function
Then to put the actual disk label into a text box I have...
VB Code:
vi2 = GetVolumeInfo(letter) Text23 = vi2.VolumeName
It works and I put the above two lines into a timer in order to get the text box updated. However no matter how fast I set the timer, like 100ms, 200ms, 500ms, there is always a massive delay.
Eg. Say I have AMERICAN PIE in at the minute. My text box shows it fine. Now I eject the tray and the text box will stay saying AMERICAN PIE for about 8 seconds. The whole program seems to freeze up for those few seconds.
Has anyone got any better code for getting the disk name. Looking in "MY COMPUTER", windows updates the disk name in a split second.
Any help would be greatly appreciated. I tried using windows own code to get notified when a disk was inserted but I couldn't get it to work if my program wasn't focused.
Thanks!!!!!!
KT




Reply With Quote