MessageQueue.GetMachineId(String) 方法


取得這個 MessageQueue 參考之佇列所在位置的電腦識別項。Gets the identifier of the computer on which the queue referenced by this MessageQueue is located.

 static Guid GetMachineId(System::String ^ machineName);
public static Guid GetMachineId (string machineName);
static member GetMachineId : string -> Guid
Public Shared Function GetMachineId (machineName As String) As Guid



包含佇列的電腦名稱,前端沒有兩條反斜線 (\\)。The name of the computer that contains the queue, without the two preceding backslashes (\\).



Guid,表示佇列所在之電腦的唯一識別項。A Guid that represents a unique identifier for the computer on which the queue is located.


無法擷取電腦識別項,可能是因為目錄服務無法使用;例如,如果您是離線工作。The computer identifier could not be retrieved, possibly because the directory service is not available; for example, if you are working offline.


存取訊息佇列方法時發生錯誤。An error occurred when accessing a Message Queuing method.


下列程式碼範例呼叫 GetMachineId(String)The following code example calls GetMachineId(String).

// Get the name of the computer that contains the queue.
string machineName = queue.MachineName;

// Display the return value of the MessageQueue.GetMachineId method.
Console.WriteLine("MessageQueue.GetMachineId(): {0}",


您可以使用電腦的識別碼來進行兩種用途:讀取電腦日誌以及設定安全性憑證。You can use a computer's identifier for two purposes, among others: to read the computer journal and to set security certificates. 但是, GetMachineId(String) 當您離線工作時,您無法呼叫遠端電腦,因為應用程式必須能夠存取網域控制站上的目錄服務。However, you cannot call GetMachineId(String) for a remote computer when you are working offline because the application must have access to the directory service on the domain controller.

電腦識別碼 (或電腦識別碼) 是 Guid 訊息佇列在將電腦新增到企業時所建立的。The computer identifier (or machine identifier) is a Guid that Message Queuing creates when a computer is added to the enterprise. 訊息佇列會結合電腦識別碼與 MachineJournal 關鍵字,以建立具有語法的電腦日誌格式名稱 Machine=<computeridentifier>;JournalMessage Queuing combines the computer identifier with the Machine and Journal keywords to create the machine journal's format name, which has the syntax Machine=<computeridentifier>;Journal. 電腦日誌(也稱為「日誌佇列」)是一個系統佇列,當屬性為時,會儲存應用程式產生之訊息的複本 UseJournalQueue trueThe machine journal, which is also known as the journal queue, is a system queue that stores copies of application-generated messages when the UseJournalQueue property is true.

只有在建立佇列的格式名稱時,才會對此日誌語法有效。This syntax for the journal is only valid when constructing the format name for the queue. 路徑名稱語法為 MachineName \ Journal$The path name syntax is MachineName\Journal$.

下表顯示此方法是否適用于各種工作組模式。The following table shows whether this method is available in various Workgroup modes.

工作組模式Workgroup mode 可用Available
本機電腦Local computer No
本機電腦和直接格式名稱Local computer and direct format name No
遠端電腦Remote computer No
遠端電腦和直接格式名稱Remote computer and direct format name No