强制布尔值(15)

Discussion in 'Object Pascal' started by terry_zhou82, Nov 15, 2010.

  1. te

    terry_zhou82 New Member Member

    比如说有个变量,TEXT,我想让他始终等于FALSE,改怎么弄?TEXT:=NOT TEXT?
     
  2. zb

    zbdzjx New Member Member

    那就定义成常量啊!!!!
     
  3. te

    terry_zhou82 New Member Member

    代码如下://希望WIN7始终不是静音。procedure TForm1.Timer1Timer(Sender: TObject);const bMute=False;var deviceEnumerator: IMMDeviceEnumerator
    defaultDevice: IMMDevice
    endpointVolume: IAudioEndpointVolume;begin CoCreateInstance(CLASS_IMMDeviceEnumerator, nil, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, deviceEnumerator)
    deviceEnumerator.GetDefaultAudioEndpoint(eRender, eConsole, defaultDevice)
    defaultDevice.Activate(IID_IAudioEndpointVolume, CLSCTX_INPROC_SERVER, nil, endpointVolume)
    endpointVolume.GetMute(bmute);end;end.哪里错了啊,总是显示“[DCC Error] Unit1.pas(38): E2033 Types of actual and formal var parameters must be identical”
     
  4. Go

    GodIsWrong New Member Member

    endpointVolume.GetMute(bmute)
    估计里面的变量是可修改的var类型,你传进去的是不可修改的const类型,不一致
     
  5. te

    terry_zhou82 New Member Member

    我看了MSDN.发现可以用SetMute函数,但里面有个参数叫PGUID,我就傻了。这个是什么类型啊