Export (0) Print
Expand All
Expand Minimize

LanguageService.IsMacroRecordingOn Method

Called to determine if macro recording is turned on.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.12.0 (in Microsoft.VisualStudio.Package.LanguageService.12.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)

public bool IsMacroRecordingOn()

Return Value

Type: System.Boolean
Returns true if macro recording is on; otherwise, returns false.

Here is an example of how this method is implemented in the base LanguageService class.

using Microsoft.VisualStudio.Package;

namespace MyLanguagePackage
{
    [Guid("B614A40A-80D9-4fac-A6AD-FC2868FFF7CD")]
    public class MyLanguageService : LanguageService
    {
        public bool IsMacroRecordingOn()
        {
            IVsShell shell = this.GetService(typeof(SVsShell)) as IVsShell;
            if (shell != null)
            {
                object pvar;
                int hr;
                hr = shell.GetProperty( (int)__VSSPROPID.VSSPROPID_RecordState,
                                       out pvar);
                if (hr != VSConstants.S_OK)
                {
                    throw Marshal.ThrowExceptionForHR(hr);
                }
                shell = null;
                if (pvar != null)
                {
                    return ((VSRECORDSTATE)pvar == VSRECORDSTATE.VSRECORDSTATE_ON);
                }
            }
            return false;
        }
    }
}

Show:
© 2014 Microsoft