Registering a SIP Application (Unmanaged Code)
Microsoft Office Live Communications Server 2005 with SP1 |
Registering a SIP Application (Unmanaged Code)
The following code sample demonstrates how to register a SIP application from unmanaged COM code.
CComPtr<IWbemServices> spIServices; // Get the IWbemServices pointer (connect to WMI ...). // Create a new instance of the MSFT_SIPApplicationSetting class. CComBSTR sbstrClassName(L"MSFT_SIPApplicationSetting"); CComPtr<IWbemClassObject> spIWbemClassObject; HRESULT hr = spIServices->GetObject(sbstrClassName, WBEM_FLAG_RETURN_WBEM_COMPLETE, NULL, &spIWbemClassObject;, NULL); if (FAILED(hr)) { return hr; } CComPtr<IWbemClassObject> spApplicationSettingObject; hr = spIWbemClassObject->SpawnInstance(0, &spApplicationSettingObject;); if (FAILED(hr)) { return hr; } // Set the attributes for the instance that was created. // Create a unique instance ID. OLECHAR oleszTemp[39] = {0}; GUID guid; hr = CoCreateGuid(&guid;); if (FAILED(hr)) { return hr; } // Set the 'InstanceID' field to the unique GUID value that was created. StringFromGUID2(guid, oleszTemp, sizeof(oleszTemp) / sizeof(OLECHAR)); CComVariant svarGuid(oleszTemp); hr = spApplicationSettingObject->Put(L"InstanceID", 0, svarGuid); if (FAILED(hr)) { return hr; } // Set the 'Name' field. CComVariant svarName(L"NameValue"); hr = spApplicationSettingObject->Put(L"Name", 0, svarName); if (FAILED(hr)) { return hr; } // Set the 'URI' field. CComVariant svarURI(L"URIValue"); hr = spApplicationSettingObject->Put(L"URI", 0, svarURI); if (FAILED(hr)) { return hr; } // Set the 'Enabled' field. CComVariant svarEnabled(true); hr = spApplicationSettingObject->Put(L"Enabled", 0, svarEnabled); if (FAILED(hr)) { return hr; } // Set the 'Critical' field. CComVariant svarCritical(false); hr = spApplicationSettingObject->Put(L"Critical", 0, svarCritical); if (FAILED(hr)) { return hr; } // Set the 'ScriptPath' field. // (only needs to be set for scriptis NULL for non-script applications) CComVariant svarScriptPath(L"ScriptPathValue"); hr = spApplicationSettingObject->Put(L"ScriptPath", 0, svarScriptPath); if (FAILED(hr)) { return hr; } // Commit the new instance to WMI. hr = spIServices->PutInstance(spApplicationSettingObject, WBEM_FLAG_CREATE_OR_UPDATE, NULL, NULL); if (FAILED(hr)) { return hr; }
What did you think of this topic? |
© 2008 Microsoft Corporation. All rights reserved. |