核心提示:unit MySynthesizers;interfaceuses Classes, SysUtils, DirectMusic, ActiveX; procedure GetSynthesizer...
unit MySynthesizers;
interface
uses
Classes, SysUtils, DirectMusic, ActiveX;
procedure GetSynthesizers(AList: TStrings);
implementation
procedure GetSynthesizers(AList: TStrings);
var
i: Integer;
APortInfo: TDMusPortCaps;
DxMusic: IDirectMusic;
begin
i := 0;
AList.Clear;
CoCreateInstance(CLSID_DirectMusic, nil, CLSCTX_INPROC, IID_IDirectMusic2, DxMusic);
//以下这句很关键,开始就是由于设少了个size,导致死活拿不到正确结果
APortInfo.dwSize := SizeOf(APortInfo);
while DxMusic.EnumPort(i, APortInfo) = S_OK do
begin
if APortInfo.dwClass = DMUS_PC_OUTPUTCLASS then
AList.Add(APortInfo.wszDescription);
inc(i);
end;
end;
initialization
CoInitialize(nil);
finalization
CoUninitialize;
end.