Commands.CommandInfo 方法
傳回與指定 Microsoft.VisualStudio.CommandBars.CommandBar 控制項關聯的命令 GUID 和 ID。
命名空間: EnvDTE
組件: EnvDTE (在 EnvDTE.dll 中)
語法
'宣告
Sub CommandInfo ( _
CommandBarControl As Object, _
<OutAttribute> ByRef Guid As String, _
<OutAttribute> ByRef ID As Integer _
)
void CommandInfo(
Object CommandBarControl,
out string Guid,
out int ID
)
void CommandInfo(
[InAttribute] Object^ CommandBarControl,
[OutAttribute] String^% Guid,
[OutAttribute] int% ID
)
abstract CommandInfo :
CommandBarControl:Object *
Guid:string byref *
ID:int byref -> unit
function CommandInfo(
CommandBarControl : Object,
Guid : String,
ID : int
)
參數
- CommandBarControl
型別:System.Object
必要項。與命令關聯的 Microsoft.VisualStudio.CommandBars.CommandBar 控制項。
- Guid
型別:System.String%
必要項。命令的 GUID。
- ID
型別:System.Int32%
必要項。命令的 ID。
範例
' Macro code.
Sub CommandInfoExample()
Dim cmds As Commands
Dim cmdobj As Command
Dim cmdbarobj As CommandBar
Dim cmdbarctl As CommandBarControl
Dim colAddins As AddIns
Dim GUID As String
Dim ID As Long
' Set references.
colAddins = DTE.AddIns()
cmds = DTE.Commands
cmdobj = cmds.Item("File.NewFile")
GUID = ""
ID = 0
' Create a toolbar and add the File.NewFile command to it.
cmdbarobj = cmds.AddCommandBar("AACmdBar", _
vsCommandBarType.vsCommandBarTypeToolbar)
MsgBox("Commandbar name: " & cmdbarobj.Name)
cmdbarctl = cmdobj.AddControl(cmdbarobj)
' Assign new GUID and ID to the command bar control.
cmds.CommandInfo(cmdbarctl, GUID, ID)
End Sub
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。