如何自动找到光驱并打开VCD文件?(10分)

J

jog81

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,找到光驱后,自动打开它的MEPGAV文件夹,应该怎么做呢?
 
procedure TForm1.Button1Click(Sender: TObject);
begin

ShellExecute(0,
'explore',
'G:/mpegav',
nil,
nil,
SW_SHOWNORMAL);
end;

 
下面代码摘自陈经韬的MPEG1解码库演示程序
即使你的光驱有多个,仍然可以打开

procedure TForm1.btVcdClick(Sender: TObject);
type
TMyCd_Rom=record
cNo:array[1..23] of char;//盘符
iCount:smallint;//光驱数
end;

PMyCd_Rom=^TMyCd_Rom;//指针
procedure GetCdRomNo(Cd_Rom:pMyCd_Rom);
var drive:char;
cdromID:integer;
begin

Cd_Rom^.iCount:=0;
for drive:='d' to 'z'do

begin

cdromID:=GetDriveType(pchar(drive+':/'));
if cdromID=5 then

begin

Cd_Rom^.iCount:=Cd_Rom.iCount+1;
Cd_Rom^.cNo[Cd_Rom.iCount]:=Drive;
end;

end;

end;

var
MyCd_Rom:pMyCd_Rom;
i:smallint;
bHaveVcdFile:Boolean;
begin

new(MyCd_Rom);
GetCdRomNo(MyCd_Rom);
if MyCd_Rom^.iCount=0 then

begin

Application.MessageBox(Msg_CDROM_NotFound,Pchar(Application.Title),MB_ICONINFORMATION+MB_OK);
Dispose(MyCd_Rom);
Exit;
end;

bHaveVcdFile:=False;
for i:=1 to MyCd_Rom.iCountdo

begin

if DirectoryExists(MyCd_Rom.cNo+':/MPEGAV') then

begin

bHaveVcdFile:=True;
Break;
end;

end;

if not(bHaveVcdFile) then

begin

Application.MessageBox(Msg_CDROM_NotFile,Pchar(Application.Title),MB_ICONINFORMATION+MB_OK);
Dispose(MyCd_Rom);
Exit;
end;

OpenDialog1.InitialDir:=MyCd_Rom.cNo+':/MPEGAV';
Dispose(MyCd_Rom);
OpenDialog1.Execute;
end;

 
多人接受答案了。
 
顶部