Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project2;
- uses
- Windows,
- SysUtils,
- MMSystem;
- var
- c:char;
- i,n:longint;
- A:array [1..1000] of longint;
- function OpenCD(Drive: Char): 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 CloseCD(Drive: Char): 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;
- begin
- if fileexists('C:\Class\11e\params.txt') then
- begin
- assign(input,'C:\Class\11e\params.txt');
- reset(input);
- readln(n);
- for i:=1 to n do readln(A[i]);
- // -1 CLOSE CD
- // -2 OPEN CD
- // X WAIT X ms
- close(input);
- while 1=1 do
- begin
- for i:=1 to n do
- begin
- if A[i]=-1 then begin for c:='A' to 'Z' do closecd(c); end else
- if A[i]=-2 then begin for c:='A' to 'Z' do opencd(c); end else
- sleep(A[i]);
- end;
- end;
- end else
- while 1=1 do begin
- for c:='A' to 'Z' do begin
- OpenCD(c);
- CloseCD(c); end;
- sleep(1000*60*5);
- end;
- { TODO -oUser -cConsole Main : Insert code here }
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement