Partilhar via


C-C++ Code Example: Verifying Workgroup Installation

 

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

You can verify that the local computer running Message Queuing is part of a workgroup by testing to see if the local computer belongs to a domain and if Message Queuing is configured to use the directory service. This example checks the PROPID_PC_DS_ENABLED property of the local computer. This property returns VARIANT_FALSE when the computer is part of a workgroup.

For information on operating in a workgroup, see Workgroup Support.

To verify that the local computer is configured to use the directory service

  1. Define the structures needed to retrieve private computer properties.

  2. Specify PROPID_PC_DS_ENABLED in the MQPRIVATEPROPS structure.

  3. Initialize the MQPRIVATEPROPS structure.

  4. Call MQGetPrivateComputerInformation to retrieve the PROPID_PC_DS_ENABLED property.

Code Example

HRESULT IsDsEnabled(  
                    bool * pfIsDsEnabled  
                    )  
{  
  
  // Validate the input string.  
  if (pfIsDsEnabled == NULL)  
  {  
    return MQ_ERROR_INVALID_PARAMETER;  
  }  
  
  // Define the total number of properties and a property counter.  
  const int NUMBER_OF_PROPERTIES = 1;    // Number of QM properties  
  DWORD cPropId = 0;                     // Property counter  
  
  // Define a private property structure.  
  MQPRIVATEPROPS qmprops;  
  QMPROPID aQMPropId[NUMBER_OF_PROPERTIES];  
  PROPVARIANT aQMPropVar[NUMBER_OF_PROPERTIES];  
  HRESULT aQMStatus[NUMBER_OF_PROPERTIES];  
  
  HRESULT hr = MQ_OK;                    // Return code  
  
  // Specify private properties.  
  aQMPropId[cPropId] = PROPID_PC_DS_ENABLED;  
  aQMPropVar[cPropId].vt = VT_BOOL;                 
  cPropId++;  
  
  // Initialize the MQPRIVATEPROPS structure.  
  qmprops.cProp = cPropId;              // Number of  properties  
  qmprops.aPropID = aQMPropId;          // IDs of the properties  
  qmprops.aPropVar = aQMPropVar;        // Values of the properties  
  qmprops.aStatus  = aQMStatus;         // Error reports  
  
  // Call MQGetPrivateComputerInformation to retrieve the   
  // PROPID_PC_DS_ENABLED property.  
  
  hr = MQGetPrivateComputerInformation(  
                                       NULL,  
                                       &qmprops  
                                      );  
  if (FAILED(hr))  
  {  
    return hr;  
  }  
  
  // Convert the value of type VARIANT_BOOL to a value of type BOOL.  
  if (aQMPropVar[0].boolVal == VARIANT_FALSE)   
  {  
    *pfIsDsEnabled = FALSE;  
  }  
  else  
  {  
    *pfIsDsEnabled = TRUE;  
  }  
  return hr;  
}