VCD player software such as "Super Jieba" generally has a button or menu option called "Play VCD". Click to automatically play VCD movies. If the file path is fixed, it can be achieved using only the multimedia control (mmcontrol). However, for different computers, because the number of logical partitions on the hard disk is different, the path of the optical disc drive is likely to be different. How is it achieved? Below, please see my detailed analysis:
Use "regedit.exe" to view the attribute items of the CD-ROM drive (hkey_local_machine, enum, scsi) in the Windows 98 registry, and compare the attribute items of the hard disk drive (hkey_local_machine, enum, esdi) with the floppy disk drive
Attribute items (hkey_local_machine, enum, flop), you can find: different disk bodies are distinguished by the parameter "devicetype". The devicetype of the hard disk is "0", the floppy disk is "0a", and the optical disk drive is "5" ". Then use "devicetype" as the keyword to search for the programming manual about win32API, and you can get the function "getdevicetype" that identifies different disks.
With this function, you can get the drive letter of the CD-ROM drive using the following sentence:
IfGetDriveType("d:/")<>5Then
IfGetDriveType("e:/")<>5Then
IfGetDriveType("f:/")<>5Then
IfGetDriveType("g:/")<>5Then
drivecd="H"
GoTogetcdfiles
EndIf
drivecd="G"
GoTogetcdfiles
EndIf
drivecd="F"
GoTogetcdfiles
EndIf
drivecd="E"
GoTogetcdfiles
Else
drivecd="D"
EndIf
getcdfiles:
The program uses the exhaustive method to determine whether the device type of the D, E, F, and G disks is "5". If they are not, the optical disk drive is H (there are not many machines with drive letters exceeding H, so the exhaustive list ends here), and we get The "drivecd" is the drive letter of the CD-ROM drive.
Because the path of all VCD movies is /mpegav/, you can use the VB function "Dir()" to get the complete playback path:
MMControl1.FileName=drivecd&":/Mpegav/"&Dir(drivecd&":/Mpegav/*.dat").
The following source program specifically implements automatic VCD playback. There is only one multimedia control in the program form - MMcontrol1. Once the program is run, it will automatically play from the first file. Press the "next" key on the multimedia control to play the next file.
'Declare the GetDriveType function
PRivateDeclareFunctionGetDriveTypeLib"kernel32"Alias"GetDriveTypeA"(ByValnDriveAsString)AsLong
Dimfiles()AsString
DimdrivecdAsString
DimiAsInteger
DimjAsInteger
PrivateSubForm_Load()
'Determine the drive letter of the CD-ROM drive
IfGetDriveType("d:/")<>5Then
IfGetDriveType("e:/")<>5Then
IfGetDriveType("f:/")<>5Then
IfGetDriveType("g:/")<>5Then
drivecd="H"
GoTogetcdfiles
EndIf
drivecd="G"
GoTogetcdfiles
EndIf
drivecd="F"
GoTogetcdfiles
EndIf
drivecd="E"
GoTogetcdfiles
Else
drivecd="D"
EndIf
'Put all VCD files into array files()
getcdfiles:
OnErrorGoTocderr:
s=Dir(drivecd&":/Mpegav/*.dat")
i=1
Whiles<>""
ReDimPreservefiles(i)AsString
files(i)=s
i=i 1
s=Dir()
Wend
j=1
Callvcdplay
OnErrorGoTo0
ExitSub
cderr:
MsgBox"CDisnotready!"
UnloadMe
EndSub
'Determine whether to play the next file
PrivateSubMMControl1_StatusUpdate()
IfMMControl1.Position=MMControl1.LengthThen
j=j 1
Ifj>i-1Thenj=1
Callvcdplay
EndIf
EndSub
'Play VCD file
PrivateSubvcdplay()
MMControl1.Command="stop"
MMControl1.Command="close"
MMControl1.FileName=drivecd&":/Mpegav/"&files(j)
MMControl1.Command="open"
MMControl1.Command="play"
EndSub
The above program passed on Chinese Windows98 and VisualBasic6.0. ->