如何根据进程ID得到它的线程ID?tid:=GetWindowThreadProcessId(WndHandle, PID);只能得到有窗口的文件的线程!如果一个进程没有窗口如何得到它的线程id?比如说如何得到winlogon。exe的线程ID??请指点!!谢谢!![我把API的书从头到尾翻了一遍,也没有由进程ID得到线程id的相关函数]

解决方案 »

  1.   

    没想到csdn上也有人基础也这么弱!
      

  2.   

    波形音量:
    function GetWaveVolume(var Value: Byte; var ErrorStr: String): Boolean;
    var
      Error: LongInt;
      hMix: HMIXER;
      Ml: MIXERLINE;
      Mc: MIXERCONTROL;
      Mlc: MIXERLINECONTROLS;
      Mcd: TMIXERCONTROLDETAILS;
      Mcdu: MIXERCONTROLDETAILS_UNSIGNED;
    begin
      Error := mixerOpen(@hMix, 0, 0, 0, 0);
      Result := Error = MMSYSERR_NOERROR;
      if Result then begin
        try
          ml.cbStruct        := sizeof(MIXERLINE);
          ml.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
         // get the Wave line of the mixer device
          Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
          Result := Error = MMSYSERR_NOERROR;
          if Result then begin
            mlc.cbStruct      := sizeof(MIXERLINECONTROLS);
            mlc.dwLineID      := ml.dwLineID;
            mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
            mlc.cControls     := 1;
            mlc.pamxctrl      := @mc;
            mlc.cbmxctrl      := sizeof(MIXERCONTROL);
            // get the volume controls associated with the Waveout line
            Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
            REsult := MMSYSERR_NOERROR = Error;
            if Result then begin
              mcdu.dwValue    := Round(Mc.Bounds.dwMaximum * (Value / 100));
              mcd.cbStruct    := sizeof(TMIXERCONTROLDETAILS);
              mcd.hwndOwner   := 0;
              mcd.dwControlID := mc.dwControlID;
              mcd.paDetails   := @mcdu;
              mcd.cbDetails   := sizeof(MIXERCONTROLDETAILS_UNSIGNED);
              mcd.cChannels   := 1;
              // set the volume
              Error := mixerGetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE);
              Value := Round((mcdu.dwValue * 100)/Mc.Bounds.dwMaximum);
              Result := Error = MMSYSERR_NOERROR;
              if not Result then ErrorStr := 'MixerGetControlDetails() Failed!';
            end else ErrorStr := 'MixerGetLineControls() Failed!';
          end else ErrorStr := 'MixerGetLineInfo() Failed!';
        finally
          MixerClose(hMix);
        end;
      end else ErrorStr := 'MixerOpen() Failed!';
    end;
    function SetWaveVolume(const Value: Byte; var ErrorStr: String): Boolean;
    var
      Error: LongInt;
      hMix: HMIXER;
      Ml: MIXERLINE;
      Mc: MIXERCONTROL;
      Mlc: MIXERLINECONTROLS;
      Mcd: TMIXERCONTROLDETAILS;
      Mcdu: MIXERCONTROLDETAILS_UNSIGNED;
    begin
      Error := mixerOpen(@hMix, 0, 0, 0, 0);
      Result := Error = MMSYSERR_NOERROR;
      if Result then begin
        try
          ml.cbStruct        := sizeof(MIXERLINE);
          ml.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
         // get the Wave line of the mixer device
          Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
          Result := Error = MMSYSERR_NOERROR;
          if Result then begin
            mlc.cbStruct      := sizeof(MIXERLINECONTROLS);
            mlc.dwLineID      := ml.dwLineID;
            mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
            mlc.cControls     := 1;
            mlc.pamxctrl      := @mc;
            mlc.cbmxctrl      := sizeof(MIXERCONTROL);
            // get the volume controls associated with the Waveout line
            Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
            REsult := MMSYSERR_NOERROR = Error;
            if Result then begin
              mcdu.dwValue    := Round(Mc.Bounds.dwMaximum * (Value / 100));
              mcd.cbStruct    := sizeof(TMIXERCONTROLDETAILS);
              mcd.hwndOwner   := 0;
              mcd.dwControlID := mc.dwControlID;
              mcd.paDetails   := @mcdu;
              mcd.cbDetails   := sizeof(MIXERCONTROLDETAILS_UNSIGNED);
              mcd.cChannels   := 1;
              // set the volume
              Error := mixerSetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE);
              Result := Error = MMSYSERR_NOERROR;
              if not Result then ErrorStr := 'MixerSetControlDetails() Failed!';
            end else ErrorStr := 'MixerGetLineControls() Failed!';
          end else ErrorStr := 'MixerGetLineInfo() Failed!';
        finally
          MixerClose(hMix);
        end;
      end else ErrorStr := 'MixerOpen() Failed!';
    end;
      

  3.   

    主音量:
    function GetMasterVolume(var Value: Byte; var ErrorStr: String): Boolean;
    var
      Error: LongInt;
      hMix: HMIXER;
      Ml: MIXERLINE;
      Mc: MIXERCONTROL;
      Mlc: MIXERLINECONTROLS;
      Mcd: TMIXERCONTROLDETAILS;
      Mcdu: MIXERCONTROLDETAILS_UNSIGNED;
    begin
      Error := mixerOpen(@hMix, 0, 0, 0, 0);
      Result := Error = MMSYSERR_NOERROR;
      if Result then begin
        try
          ml.cbStruct        := sizeof(MIXERLINE);
          ml.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
         // get the speaker line of the mixer device
          Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
          Result := Error = MMSYSERR_NOERROR;
          if Result then begin
            mlc.cbStruct      := sizeof(MIXERLINECONTROLS);
            mlc.dwLineID      := ml.dwLineID;
            mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
            mlc.cControls     := 1;
            mlc.pamxctrl      := @mc;
            mlc.cbmxctrl      := sizeof(MIXERCONTROL);
            // get the volume controls associated with the speaker line
            Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
            REsult := MMSYSERR_NOERROR = Error;
            if Result then begin
              mcdu.dwValue    := Round(Mc.Bounds.dwMaximum * (Value / 100));
              mcd.cbStruct    := sizeof(TMIXERCONTROLDETAILS);
              mcd.hwndOwner   := 0;
              mcd.dwControlID := mc.dwControlID;
              mcd.paDetails   := @mcdu;
              mcd.cbDetails   := sizeof(MIXERCONTROLDETAILS_UNSIGNED);
              mcd.cChannels   := 1;
              // set the volume
              Error := mixerGetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE);
              Value := Round(mcdu.dwValue * 100 / Mc.Bounds.dwMaximum);
              Result := Error = MMSYSERR_NOERROR;
              if not Result then ErrorStr := 'MixerGetControlDetails() Failed!';
            end else ErrorStr := 'MixerGetLineControls() Failed!';
          end else ErrorStr := 'MixerGetLineInfo() Failed!';
        finally
          MixerClose(hMix);
        end;
      end else ErrorStr := 'MixerOpen() Failed!';
    end;function SetMasterVolume(const Value: Byte; var ErrorStr: String): Boolean;
    var
      Error: LongInt;
      hMix: HMIXER;
      Ml: MIXERLINE;
      Mc: MIXERCONTROL;
      Mlc: MIXERLINECONTROLS;
      Mcd: TMIXERCONTROLDETAILS;
      Mcdu: MIXERCONTROLDETAILS_UNSIGNED;
    begin
      Error := mixerOpen(@hMix, 0, 0, 0, 0);
      Result := Error = MMSYSERR_NOERROR;
      if Result then begin
        try
          ml.cbStruct        := sizeof(MIXERLINE);
          ml.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
         // get the speaker line of the mixer device
          Error := mixerGetLineInfo(hMix, @ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
          Result := Error = MMSYSERR_NOERROR;
          if Result then begin
            mlc.cbStruct      := sizeof(MIXERLINECONTROLS);
            mlc.dwLineID      := ml.dwLineID;
            mlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
            mlc.cControls     := 1;
            mlc.pamxctrl      := @mc;
            mlc.cbmxctrl      := sizeof(MIXERCONTROL);
            // get the volume controls associated with the speaker line
            Error := mixerGetLineControls(hMix, @mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
            REsult := MMSYSERR_NOERROR = Error;
            if Result then begin
              mcdu.dwValue    := Round(Mc.Bounds.dwMaximum * (Value / 100));
              mcd.cbStruct    := sizeof(TMIXERCONTROLDETAILS);
              mcd.hwndOwner   := 0;
              mcd.dwControlID := mc.dwControlID;
              mcd.paDetails   := @mcdu;
              mcd.cbDetails   := sizeof(MIXERCONTROLDETAILS_UNSIGNED);
              mcd.cChannels   := 1;
              // set the volume
              Error := mixerSetControlDetails(hMix, @mcd, MIXER_SETCONTROLDETAILSF_VALUE);
              Result := Error = MMSYSERR_NOERROR;
              if not Result then ErrorStr := 'MixerSetControlDetails() Failed!';
            end else ErrorStr := 'MixerGetLineControls() Failed!';
          end else ErrorStr := 'MixerGetLineInfo() Failed!';
        finally
          MixerClose(hMix);
        end;
      end else ErrorStr := 'MixerOpen() Failed!';
    end;
      

  4.   

    不好意思,回答错了,应该是对它的回答:http://community.csdn.net/Expert/topic/3954/3954023.xml?temp=.4978754