Delen via


MSMQApplication.MachineIdOfMachineName

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

The MachineIdOfMachineName method of the MSMQApplication object returns the globally unique identifier (GUID) for a specified computer.

The computer GUID is used to create a private format name for a private queue, a machine format name for the computer journal, or a machine format name for a dead-letter queue. For information on the syntax of machine format names, see Machine and Connector Format Names.

Function MachineIdOfMachineName( _  
ByVal MachineName As String _  
) As String  
Parameters  
MachineName  
[in] String containing the name of the computer.  

Return Values

A String containing the computer GUID in the form 12345678-1234-1234-1234-123456789ABC. Note that the string returned by this method does not include the braces normally used with GUIDs.

Error Codes

This method also generates one of the following error codes:

MQ_OK (0L)

Indicates success.

MQ_ERROR_ACCESS_DENIED (0xC00E0025L)

Access to the specified computer is denied. Verify whether the access rights of the computer for performing the operation are allowed for the caller.

MQ_ERROR_MACHINE_NOT_FOUND (0xC00E0000DL)

The specified computer could not be found in the directory service.

MQ_ERROR_NO_DS (0xC00E0013L)

Cannot access the directory service. Verify permissions for accessing the directory service.

For a complete list of error and information codes, see Message Queuing Error and Information Codes.

Remarks

The computer GUID is generated by Message Queuing when the computer is defined (for dependent clients, Message Queuing sets this property to the GUID of the dependent client's supporting server).

To retrieve the GUID of the local computer, use the Visual BasicĀ® constant vbNullString as shown in the following example statement.

strMachineId = MSMQApplication.MachineIdOfMachineName
(vbNullString)  

When you call MachineIdOfMachineName, you do not have to reference the MSMQApplication object explicitly because this object is defined as the application object, whose methods and properties are globally available. For example, the following lines of code both return the GUID of the local computer.

strMachineId = MachineIdOfMachineName
(vbNullString)  
strMachineId = MSMQApplication.MachineIdOfMachineName
(vbNullString)  

Applications operating offline cannot call MachineIdOfMachineName while they are offline. An MQ_ERROR_NO_DS error code is returned if this call is attempted while operating offline. Message Queuing must have access to the directory service to retrieve the GUID of a computer.

For information on offline operations, see Message Queuing Offline Support.

Equivalent API Function Property

With API functions, the equivalent property is PROPID_QM_MACHINE_ID.

Example Code

The following example is included in Using Message Queuing.

For an example of See
Retrieving the computer GUID to read messages from the computer journal C/C++ Code Example: Reading Messages in the Computer Journal

Requirements

Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.

Windows 95/98/Me: Included in Windows 95 and later.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.

See Also

MSMQApplication
PROPID_QM_MACHINE_ID