LanguageService.IsMacroRecordingOn 方法

调用确定宏记录是否打开。

命名空间:  Microsoft.VisualStudio.Package
程序集:   Microsoft.VisualStudio.Package.LanguageService.9.0(在 Microsoft.VisualStudio.Package.LanguageService.9.0.dll 中)
  Microsoft.VisualStudio.Package.LanguageService.10.0(在 Microsoft.VisualStudio.Package.LanguageService.10.0.dll 中)
  Microsoft.VisualStudio.Package.LanguageService.11.0(在 Microsoft.VisualStudio.Package.LanguageService.11.0.dll 中)
  Microsoft.VisualStudio.Package.LanguageService(在 Microsoft.VisualStudio.Package.LanguageService.dll 中)

语法

声明
Public Function IsMacroRecordingOn As Boolean
public bool IsMacroRecordingOn()

返回值

类型:System.Boolean
,如果宏记录打开,则返回; true 否则,返回 false。

示例

这是示例的此方法在基 LanguageService 类执行。

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;
        }
    }
}

.NET Framework 安全性

请参见

参考

LanguageService 类

Microsoft.VisualStudio.Package 命名空间