home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kompon / d2345 / MSYSINFO.ZIP / Source / MSI_Media.pas < prev    next >
Pascal/Delphi Source File  |  2001-05-21  |  6KB  |  204 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       MiTeC System Information Component              }
  5. {               Media Detection Part                    }
  6. {           version 5.4 for Delphi 3,4,5                }
  7. {                                                       }
  8. {       Copyright ⌐ 1997,2001 Michal Mutl               }
  9. {                                                       }
  10. {*******************************************************}
  11.  
  12. {$INCLUDE MITEC_DEF.INC}
  13.  
  14. unit MSI_Media;
  15.  
  16. interface
  17.  
  18. uses
  19.   SysUtils, Windows, Classes, MMSystem;
  20.  
  21. type
  22.   TMedia = class(TPersistent)
  23.   private
  24.     FDevice,
  25.     FAUX,
  26.     FMIDIIn,
  27.     FMixer,
  28.     FWAVEOut,
  29.     FWAVEIn,
  30.     FMIDIOut: TStrings;
  31.     FSCI: integer;
  32.     FGPI: integer;
  33.   public
  34.     constructor Create;
  35.     destructor Destroy; override;
  36.     procedure GetInfo;
  37.     procedure Report(var sl :TStringList);
  38.   published
  39.     property GamePortIndex: integer read FGPI write FGPI stored false;
  40.     property SoundCardIndex: integer read FSCI write FSCI stored False;
  41.     property Devices :TStrings read FDevice write FDevice stored false;
  42.     property WAVEIn :TStrings read FWAVEIn write FWAVEIn stored false;
  43.     property WAVEOut :TStrings read FWAVEOut write FWAVEOut stored false;
  44.     property MIDIIn :TStrings read FMIDIIn write FMIDIIn stored false;
  45.     property MIDIOut :TStrings read FMIDIOut write FMIDIOut stored false;
  46.     property AUX :TStrings read FAUX write FAUX stored false;
  47.     property Mixer :TStrings read FMixer write FMixer stored false;
  48.   end;
  49.  
  50. implementation
  51.  
  52. uses Registry, MiTeC_Routines, MSI_Devices;
  53.  
  54. { TMedia }
  55.  
  56. constructor TMedia.Create;
  57. begin
  58.   inherited;
  59.   FDevice:=TStringList.Create;
  60.   FWaveIn:=TStringList.Create;
  61.   FWaveOut:=TStringList.Create;
  62.   FMIDIIn:=TStringList.Create;
  63.   FMIDIOut:=TStringList.Create;
  64.   FMixer:=TStringList.Create;
  65.   FAUX:=TStringList.Create;
  66. end;
  67.  
  68. destructor TMedia.Destroy;
  69. begin
  70.   FDevice.Free;
  71.   FWaveIn.Free;
  72.   FWaveOut.Free;
  73.   FMIDIIn.Free;
  74.   FMIDIOut.Free;
  75.   FMixer.Free;
  76.   FAUX.Free;
  77.   inherited;
  78. end;
  79.  
  80. procedure TMedia.GetInfo;
  81. var
  82.   WOC :PWAVEOutCaps;
  83.   WIC :PWAVEInCaps;
  84.   MOC :PMIDIOutCaps;
  85.   MIC :PMIDIInCaps;
  86.   AXC :PAUXCaps;
  87.   MXC :PMixerCaps;
  88.   i,j,n: integer;
  89.   s: string;
  90. const
  91.   rv = 'DriverDesc';
  92.   rvMediaClass = 'MEDIA';
  93. begin
  94.   try
  95.  
  96.   FDevice.Clear;
  97.   GetClassDevices(ClassKey,rvMediaClass,DescValue,FDevice);
  98.   FSCI:=-1;
  99.   FGPI:=-1;
  100.  
  101.   with TDevices.Create do begin
  102.     GetInfo;
  103.     for i:=0 to DeviceCount-1 do
  104.       if Devices[i].DeviceClass=dcMEDIA then begin
  105.         if Devices[i].FriendlyName='' then
  106.           s:=Devices[i].Description
  107.         else
  108.           s:=Devices[i].FriendlyName;
  109.         j:=FDevice.IndexOf(s);
  110.         if j<>-1 then begin
  111.           if pos('GAME',UpperCase(s))>0 then
  112.             FGPI:=j
  113.           else
  114.             if (Devices[i].Location<>'') and (FSCI=-1) then
  115.               FSCI:=j;
  116.         end;
  117.       end;
  118.     Free;
  119.   end;
  120.  
  121.   new(WOC);
  122.   n:=waveOutGetNumDevs;
  123.   for i:=0 to n-1 do
  124.     if WAVEOutGetDevCaps(i,WOC,SizeOf(TWAVEOutCaps))=MMSYSERR_NOERROR then begin
  125.       s:=strpas(WOC^.szPname)+' v'+inttostr(hi(WOC^.vDriverVersion))+'.'+inttostr(hi(WOC^.vDriverVersion));
  126.       if FWaveOut.IndexOf(s)=-1 then
  127.         FWAVEOut.Add(s);
  128.     end;
  129.   dispose(WOC);
  130.  
  131.   new(WIC);
  132.   n:=waveInGetNumDevs;
  133.   for i:=0 to n-1 do
  134.     if WAVEinGetDevCaps(i,WIC,SizeOf(TWAVEInCaps))=MMSYSERR_NOERROR then begin
  135.       s:=strpas(WIC^.szPname)+' v'+inttostr(hi(WIC^.vDriverVersion))+'.'+inttostr(hi(WIC^.vDriverVersion));
  136.       if FWaveIn.IndexOf(s)=-1 then
  137.         FWAVEIn.Add(s);
  138.     end;
  139.   dispose(WIC);
  140.  
  141.   new(MOC);
  142.   n:=midiOutGetNumDevs;
  143.   for i:=0 to n-1 do
  144.     if MIDIoutGetDevCaps(i,MOC,SizeOf(TMIDIOutCaps))=MMSYSERR_NOERROR then begin
  145.       s:=strpas(MOC^.szPname)+' v'+inttostr(hi(MOC^.vDriverVersion))+'.'+inttostr(hi(MOC^.vDriverVersion));
  146.       if FMIDIOut.IndexOf(s)=-1 then
  147.         FMIDIout.Add(s);
  148.     end;
  149.   dispose(MOC);
  150.  
  151.   new(MIC);
  152.   n:=midiInGetNumDevs;
  153.   for i:=0 to n-1 do
  154.     if MIDIinGetDevCaps(i,MIC,SizeOf(TMIDIInCaps))=MMSYSERR_NOERROR then begin
  155.       s:=strpas(MIC^.szPname)+' v'+inttostr(hi(MIC^.vDriverVersion))+'.'+inttostr(hi(MIC^.vDriverVersion));
  156.       if FMIDIIn.IndexOf(s)=-1 then
  157.         FMIDIin.Add(s);
  158.     end;
  159.   dispose(MIC);
  160.  
  161.   new(AXC);
  162.   n:=auxGetNumDevs;
  163.   for i:=0 to n-1 do
  164.     if AUXGetDevCaps(i,AXC,SizeOf(TAUXCaps))=MMSYSERR_NOERROR then begin
  165.       s:=strpas(AXC^.szPname)+' v'+inttostr(hi(AXC^.vDriverVersion))+'.'+inttostr(hi(AXC^.vDriverVersion));
  166.       if FAUX.IndexOf(s)=-1 then
  167.         FAUX.Add(s);
  168.     end;
  169.   dispose(AXC);
  170.  
  171.   new(MXC);
  172.   n:=mixerGetNumDevs;
  173.   for i:=0 to n-1 do
  174.     if MixerGetDevCaps(i,MXC,SizeOf(TMixerCaps))=MMSYSERR_NOERROR then begin
  175.       s:=strpas(MXC^.szPname)+' v'+inttostr(hi(MXC^.vDriverVersion))+'.'+inttostr(hi(MXC^.vDriverVersion));
  176.       if FMixer.IndexOf(s)=-1 then
  177.         FMixer.Add(s);
  178.     end;
  179.   dispose(MXC);
  180.  
  181.   except
  182.     on e:Exception do begin
  183.       MessageBox(0,PChar(e.message),'TMedia.GetInfo',MB_OK or MB_ICONERROR);
  184.     end;
  185.   end;
  186. end;
  187.  
  188. procedure TMedia.Report(var sl: TStringList);
  189. begin
  190.   with sl do begin
  191.     Add('[Media]');
  192.     StringsToRep(Devices,'Count','Device',sl);
  193.     Add('[Sound]');
  194.     StringsToRep(WaveIn,'WaveInCount','WaveIn',sl);
  195.     StringsToRep(WaveOut,'WaveOutCount','WaveOut',sl);
  196.     StringsToRep(MIDIIn,'MIDIInCount','MIDIIn',sl);
  197.     StringsToRep(MIDIIn,'MIDIOutCount','MIDIOut',sl);
  198.     StringsToRep(AUX,'AUXCount','AUX',sl);
  199.     StringsToRep(Mixer,'MixerCount','Mixer',sl);
  200.   end;
  201. end;
  202.  
  203. end.
  204.