uses ComObj, ActiveX;
//常量和变量声明及单元引用声明
var MediaPlayer, Part: Variant;
//声明为OLE Automation 对象
Filename : String;
//Filename用于存放要保存的文件的名称
const
CLSID_DelphiFormViewerContextMenu: TGUID =
'{22D6F312-B0F6-11D0-94AB-0080C74C7E95}';
function GetOLeCreateObject (const ClassName: string): IDispatch;
var //根据Windows Media Player的运行情况创建获取对象
ClassID: TGUID;
Unknown: IUnknown;
begin
ClassID := ProgIDToClassID (ClassName);
if Succeeded (GetActiveObject (ClassID, nil, Unknown)) then
OleCheck (Unknown.QueryInterface (IDispatch, Result))
else
Result := CreateOleObject (ClassName);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MediaPlayer := GetOLeCreateObject ('WMPlayer.Application');
MediaPlayer.Visible := True;
end;
。。。。。。