示例#1
0
 protected override void BeginProcessing()
 {
     this._resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly());
     this._pdhHelper = new PdhHelper(Environment.OSVersion.Version.Major < 6);
     long res = this._pdhHelper.ConnectToDataSource();
     if (res != 0)
     {
         this.ReportPdhError(res, true);
     }
     else if (this.Continuous.IsPresent && this._maxSamplesSpecified)
     {
         Exception exception = new Exception(string.Format(CultureInfo.CurrentCulture, this._resourceMgr.GetString("CounterContinuousOrMaxSamples"), new object[0]));
         base.ThrowTerminatingError(new ErrorRecord(exception, "CounterContinuousOrMaxSamples", ErrorCategory.InvalidArgument, null));
     }
 }
示例#2
0
 protected override bool ReleaseHandle()
 {
     return(PdhHelper.PdhCloseLog(base.handle, 0) == 0);
 }
示例#3
0
        //
        // BeginProcessing() is invoked once per pipeline
        //
        protected override void BeginProcessing()
        {
            _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();

            _pdhHelper = new PdhHelper(System.Environment.OSVersion.Version.Major < 6);
            uint res = _pdhHelper.ConnectToDataSource();
            if (res != 0)
            {
                ReportPdhError(res, true);
                return;
            }


            if (Continuous.IsPresent && _maxSamplesSpecified)
            {
                Exception exc = new Exception(string.Format(CultureInfo.CurrentCulture, _resourceMgr.GetString("CounterContinuousOrMaxSamples")));
                ThrowTerminatingError(new ErrorRecord(exc, "CounterContinuousOrMaxSamples", ErrorCategory.InvalidArgument, null));
            }
        }
示例#4
0
        //
        // BeginProcessing() is invoked once per pipeline
        //
        protected override void BeginProcessing()
        {
            _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();

            //
            // Determine the OS version: this cmdlet requires Windows 7
            // because it uses new Pdh functionality.
            //
            if (System.Environment.OSVersion.Version.Major < 6 ||
                (System.Environment.OSVersion.Version.Major == 6 && System.Environment.OSVersion.Version.Minor < 1))
            {
                string msg = _resourceMgr.GetString("ExportCtrWin7Required");
                Exception exc = new Exception(msg);
                ThrowTerminatingError(new ErrorRecord(exc, "ExportCtrWin7Required", ErrorCategory.NotImplemented, null));
            }

            _pdhHelper = new PdhHelper(System.Environment.OSVersion.Version.Major < 6);

            //
            // Validate the Format and CounterSamples arguments
            //            
            ValidateFormat();

            if (Circular.IsPresent && _maxSize == 0)
            {
                string msg = string.Format(CultureInfo.InvariantCulture, _resourceMgr.GetString("CounterCircularNoMaxSize"));
                Exception exc = new Exception(msg);
                WriteError(new ErrorRecord(exc, "CounterCircularNoMaxSize", ErrorCategory.InvalidResult, null));
            }

            uint res = _pdhHelper.ConnectToDataSource();
            if (res != 0)
            {
                ReportPdhError(res, true);
            }

            res = _pdhHelper.OpenQuery();
            if (res != 0)
            {
                ReportPdhError(res, true);
            }
        }
示例#5
0
 protected override bool ReleaseHandle()
 {
     return(PdhHelper.PdhCloseQuery(handle) == 0);
 }
示例#6
0
 protected override void BeginProcessing()
 {
     this._resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly());
     this._pdhHelper = new PdhHelper(Environment.OSVersion.Version.Major < 6);
 }
示例#7
0
 //
 // BeginProcessing() is invoked once per pipeline
 //
 protected override void BeginProcessing()
 {
     _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();
     _pdhHelper = new PdhHelper(System.Environment.OSVersion.Version.Major < 6);
 }