home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / misc / cdmusicc / main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  1.4 KB  |  67 lines

  1. unit Main;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: CDMUSICC }
  5.  
  6. { Example of how to call a C DLL from Delphi.
  7.   The code in the C DLL very closely parallels
  8.   the code in the Delphi PLAYER program.
  9.  
  10.   You need a CD player, and a music CD in the
  11.   player, to run this program. However, even if
  12.   you don't have a CD, you can tell that you are
  13.   calling the DLL correctly by seeing if you get
  14.   a proper error message when you hit "Play CD".
  15.   For instance, if you get a message that says
  16.   'Calling Func' or 'Return Code', then that's the DLL
  17.   talking to you. See the ErrorMsg routine in
  18.   CDINFO.CPP }
  19.  
  20. interface
  21.  
  22. uses
  23.   WinTypes, WinProcs, Classes,
  24.   Graphics, Forms, Controls,
  25.   StdCtrls;
  26.  
  27. type
  28.   TForm1 = class(TForm)
  29.     bOpenCD: TButton;
  30.     bCloseCD: TButton;
  31.     bPlayCD: TButton;
  32.     procedure bOpenCDClick(Sender: TObject);
  33.     procedure bPlayCDClick(Sender: TObject);
  34.     procedure bCloseCDClick(Sender: TObject);
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. uses
  43.   CDUnitC;
  44.  
  45. {$R *.DFM}
  46.  
  47. procedure TForm1.bOpenCDClick(Sender: TObject);
  48. begin
  49.   if OpenCD(Handle) then begin
  50.     bPlayCD.Enabled := True;
  51.     bCloseCD.Enabled := True;
  52.   end;
  53. end;
  54.  
  55. procedure TForm1.bPlayCDClick(Sender: TObject);
  56. begin
  57.   PlayCDOneTrack(1);
  58. end;
  59.  
  60. procedure TForm1.bCloseCDClick(Sender: TObject);
  61. begin
  62.   CloseCDMCI;
  63. end;
  64.  
  65. end.
  66.  
  67.