예제 #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);
 }