DELPHI Воскресенье, 05.05.2024, 18:38
Приветствую Вас Гость | RSS
Меню сайта

Разделы новостей
Статьи [1]
Примеры программ [4871]
Компоненты Delphi [3]
Секреты Delphi [1]
Полезное [92]
Мои разработки [3]

Начало » 2007 » Апрель » 20 » Открываем и закрываем CD-ROM
Открываем и закрываем CD-ROM
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, MMSystem;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
ComboBox1: TComboBox;
Button3: TButton;
procedure Button1Click(Sender: TObject);
function CloseCD(Drive : string) : Boolean;
function OpenCD(Drive : string) : Boolean;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
public
end;

var
Form1: TForm1;
Driv: array [1..25] of string;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
OpenCD(ComboBox1.Text);
end;

function TForm1.OpenCD(Drive: string): Boolean;
var
Res : MciError;
OpenParm: TMCI_Open_Parms;
Flags : DWord;
S : string;
DeviceID : Word;
begin
Result:=false;
S:=Drive;
Flags:=mci_Open_Type or mci_Open_Element;
with OpenParm do
begin
dwCallback := 0;
lpstrDeviceType := 'CDAudio';
lpstrElementName := PChar(S);
end;
Res := mciSendCommand(0, mci_Open, Flags, Longint(@OpenParm));
if Res<>0 then
exit;
DeviceID:=OpenParm.wDeviceID;
try
Res:=mciSendCommand(DeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0);
if Res=0 then
exit;
Result:=True;
finally
mciSendCommand(DeviceID, mci_Close, Flags, Longint(@OpenParm));
end;
end;

function TForm1.CloseCD(Drive: string): Boolean;
var
Res : MciError;
OpenParm: TMCI_Open_Parms;
Flags : DWord;
S : string;
DeviceID : Word;
begin
Result:=false;
S:=Drive;
Flags:=mci_Open_Type or mci_Open_Element;
with OpenParm do
begin
dwCallback := 0;
lpstrDeviceType := 'CDAudio';
lpstrElementName := PChar(S);
end;
Res := mciSendCommand(0, mci_Open, Flags, Longint(@OpenParm));
if Res<>0 then
exit;
DeviceID:=OpenParm.wDeviceID;
try
Res:=mciSendCommand(DeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, 0);
if Res=0 then
exit;
Result:=True;
finally
mciSendCommand(DeviceID, mci_Close, Flags, Longint(@OpenParm));
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
w:dword;
Root:string;
I, K:integer;
begin
k:=0;
w:=GetLogicalDrives;
Root := '#:';
for i := 0 to 25 do
begin
Root[1] := Char(Ord('A')+i);
if (W and (1 shl i))>0 then
if GetDriveType(Pchar(Root)) = DRIVE_CDROM then
begin
k:=k+1;
Driv[k] := Root;
ComboBox1.Items.Add(Driv[k]);
ComboBox1.Text := Driv[1];
end;
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
CloseCD(ComboBox1.Text);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;

end.

Категория: Примеры программ | Просмотров: 16524 | Добавил: ADMIN | Рейтинг: 5.0 |
Всего комментариев: 7
7 Travelerfum  
0
Really user pleasant site. Tremendous information offered on couple of clicks. Have a look at too my own website!

https://www.mistralbg.com/pochivki-turcia/antalia-belek почивка в турция май

ptmis+

6 RobertwRica  
0
Hello dear friend, I would like to offer placement of your link (or links) on different platforms of the internet such as: forums, blogs, comments and much more. . .

Increase your Visibility Boost Your Seo Rank - Get Organic Traffic From Google. Ranking in Google isn’t hard. All you need is a healthy number of backlinks from referring domains that have authority and trust in Google’s eyes.

This Backlinks Service Benefits:

1. Easily get Google rankings

2. Get a lot of traffic from Google

3. You can earn from the website in different ways

4. Increase Domain Authority (DA)

Quality guaranteed !

PRICE - 20$

WebSite - https://goo.su/ZUHZ

5 CheburatorPl  
0
So drnuk...
Oh..

Ltaer

4 BradMayot  
0
Wanted to express in which I have already been following this discussion board only a few months at this moment, i are available once a week. Wonderful info on that, consequently thank you web site owner pertaining to allowing united states get the following community forum !
PS : i am sorry pertaining to my own the english language, Now i'm German...

3 Евгений  
0
О1 Спасибо! Напишу пойду вирус, который будет прятаться и открывать и закрывать дисковод!

2 Макс  
0
ном..)

1 R1001D91E  
0
biggrin

Имя *:
Email *:
Код *:
Форма входа

Календарь новостей
«  Апрель 2007  »
ПнВтСрЧтПтСбВс
      1
2345678
9101112131415
16171819202122
23242526272829
30

Поиск по новостям

Друзья сайта

Статистика

Copyright MyCorp © 2006