Condividi tramite


MSMQApplication.MachineNameOfMachineId

 

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

(Introduced in MSMQ 2.0.) The MachineNameOfMachineId method of the MSMQApplication object returns the name for a computer specified by its globally unique identifier (GUID).

Function MachineNameOfMachineId( _  
ByVal bstrGUID As String _  
) As String  

Parameters

bstrGUID

[in] String containing the GUID of the computer in the form 12345678-1234-1234-1234-123456789ABC. Note that the string does not include the braces normally used with GUIDs.

Return Values

A String containing the DNS name (if one is available) or UNC name of the computer.

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_ILLEGAL_PROPERTY_VALUE (0xC00E00018L)

The GUID supplied to the bstrGUID parameter is not formatted correctly.

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 MachineNameOfMachineId property returns the DNS path name of the computer, if possible. If the DNS path name cannot be generated, the UNC path name of the computer is returned instead.

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

strMachineName = MSMQApplication.MachineNameOfMachineId
(vbNullString)  

When you call MachineNameOfMachineId, 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 line of code also returns the name of the local computer.

strMachineName = MachineNameOfMachineId
(vbNullString)  

To retrieve the name of the computer that sent a message, use the MSMQMessage.SourceMachineGuid message property as shown below.

strMachineName = MachineNameOfMachineId
(msg.SourceMachineGuid)  

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 name of a computer specified by its GUID.

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

In C++ COM applications, you must use a smart pointer to the IMSMQApplication2 or IMSMQApplication3 interface to expose the MachineIdOfMachineName method.

Equivalent API Function Property

With API functions, the equivalent property is PROPID_QM_PATHNAME_DNS.

Requirements

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

Windows 95/98/Me: Unsupported.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.

See Also

MSMQApplication
MSMQMessage.SourceMachineGuid