Thema: Delphi TV-Karte stummschalten

Einzelnen Beitrag anzeigen

laserflor

Registriert seit: 8. Sep 2005
Ort: Berlin
6 Beiträge
 
Delphi 5 Professional
 
#7

Re: TV-Karte stummschalten

  Alt 27. Jun 2007, 20:23
Nach auswerten der verschiedenen Links, die mir geholfen haben, fasse ich hier zusammen:
[code=delphi]program StartTV;

uses Windows, Sysutils, Mmsystem;

function GetMixer(compType: DWORD; var Control: TMixerControl): MMResult;
var
Line: TMixerLine;
Controls: TMixerLineControls;
begin
ZeroMemory(@Line, SizeOf(Line));
Line.cbStruct:= SizeOf(Line);
Line.dwComponentType:= compType;
Result:= mixerGetLineInfo(0, @Line, MIXER_GETLINEINFOF_COMPONENTTYPE);
if Result = MMSYSERR_NOERROR then
begin
ZeroMemory(@Controls, SizeOf(Controls));
Controls.cbStruct:= SizeOf(Controls);
Controls.dwLineID:= Line.dwLineID;
Controls.cControls:= 1;
Controls.dwControlType:= MIXERCONTROL_CONTROLTYPE_MUTE;
Controls.cbmxctrl:= SizeOf(Control);
Controls.pamxctrl:= @Control;
Result:= mixerGetLineControls(0, @Controls, MIXER_GETLINECONTROLSF_ONEBYTYPE);
end;
end;

procedure SetMute(dwcompType: DWORD; Value: Boolean);
var
Mixer: TMixerControl;
Details: TMixerControlDetails;
BoolDetails: TMixerControlDetailsBoolean;
Code: MMResult;
begin
Code:= GetMixer(dwcompType, Mixer);
if Code = MMSYSERR_NOERROR then
begin
with Details do
begin
cbStruct:= SizeOf(Details);
dwControlID:= Mixer.dwControlID;
cChannels:= 1;
cMultipleItems := 0;
cbDetails:= SizeOf(BoolDetails);
paDetails:= @BoolDetails;
end;
LongBool(BoolDetails.fValue):= Value;
Code:= mixerSetControlDetails(0, @Details, MIXER_SETCONTROLDETAILSF_VALUE);
end;
if Code <> MMSYSERR_NOERROR
then
raise Exception.CreateFmt('SetMuteValue failure, '+
'multimedia system error #%d',
Code:
);
end;

procedure WaitExecute(sEXE: String);
var
  aTSI: TStartupInfo;
  aTPI: TProcessInformation;
  iRet: Integer;
begin
  FillChar(aTSI, SizeOf(aTSI), #0);
  FillChar(aTPI, SizeOf(aTPI), #0);
  aTSI.CB := SizeOf(aTSI);
  if not CreateProcess(nil, PChar(sEXE), nil, nil, False,
                       NORMAL_PRIORITY_CLASS,
                       nil, nil, aTSI, aTPI)
  then
    RaiseLastWin32Error;
  SetMute(MIXERLINE_COMPONENTTYPE_SRC_LINE, false);
  { TMixerLine.dwComponentType
    component types for destinations and sources

    findet man in der mmsystem.pas}

  repeat
    iRet := MsgWaitForMultipleObjects(1, aTPI.hProcess, False, INFINITE,
                                     (QS_ALLINPUT));
  until iRet = (WAIT_OBJECT_0);
  SetMute(MIXERLINE_COMPONENTTYPE_SRC_LINE, true);
  CloseHandle(aTPI.hProcess);
end;

begin
  WaitExecute('C:\Programme\TC Capture Card\HDTV.EXE');
end.
Damit ist die Frage erledigt.
Vielleicht kann man ja den Code mit ein bisschen Schliff in die Codelib bringen.
  Mit Zitat antworten Zitat