Set Application Properties Example for C++

HRESULT SetApplicationProperties(IltmsServer* server) 
{ 
   HRESULT hr; 
   CComPtr<IltmsApplicationProperties> props; 
 
   // retrieve a copy of the current application properties 
   hr = server->GetApplicationProperties(&props); 
   if(FAILED(hr)) 
      goto error; 
 
   // remove any existing values 
   hr = props->Clear(); 
   if(FAILED(hr)) 
      goto error; 
 
   // set up various user-defined properties 
   hr = props->AddString(CComBSTR(L"String"), CComBSTR(L"test string")); 
   if(FAILED(hr)) 
      goto error; 
 
   hr = props->AddInteger(CComBSTR(L"Integer"), 37); 
   if(FAILED(hr)) 
      goto error; 
 
   hr = props->AddNumber(CComBSTR(L"Number"), 3.14); 
   if(FAILED(hr)) 
      goto error; 
 
   hr = props->AddNumber(CComBSTR(L"Boolean"), VARIANT_FALSE); 
   if(FAILED(hr)) 
      goto error; 
 
   hr = props->AddString(CComBSTR(L"Path"), CComBSTR(L"%ltmsRootFolder%\\dummy")); 
   if(FAILED(hr)) 
      goto error; 
 
   // add a property and delete it 
   hr = props->AddString(CComBSTR(L"Temp"), CComBSTR(L"dummy")); 
   if(FAILED(hr)) 
      goto error; 
 
   hr = props->Remove(CComBSTR(L"Temp")); 
   if(FAILED(hr)) 
      goto error; 
 
   // now print them out for debug 
   { 
      CComBSTR v; 
      hr = props->GetString(CComBSTR(L"String"), &v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("String = %s\n"), (LPCTSTR) CString(v)); 
 
   } 
   { 
      LONG v; 
      hr = props->GetInteger(CComBSTR(L"Integer"), &v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("Integer = %ld\n"), v); 
 
   } 
   { 
      double v; 
      hr = props->GetNumber(CComBSTR(L"Number"), &v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("Number = %g\n"), v); 
 
   } 
   { 
      VARIANT_BOOL v; 
      hr = props->GetBoolean(CComBSTR(L"Boolean"), &v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("Boolean = %s\n"), (v != VARIANT_FALSE) ? _T("true") : _T("false")); 
 
   } 
   { 
      CComBSTR v; 
      hr = props->GetResolvedPath(CComBSTR(L"Path"), &v); 
      if(FAILED(hr)) 
         goto error; 
      _tprintf(_T("Path = %s\n"), (LPCTSTR) CString(v)); 
 
   } 
   { 
      CComBSTR v; 
      hr = props->GetString(CComBSTR(L"Temp"), &v); 
      if(FAILED(hr)) 
         _tprintf(_T("Temp does not exist\n")); 
      else 
         _tprintf(_T("Temp = %s\n"), (LPCTSTR) CString(v)); 
 
   } 
 
   // copy the properties to the server 
   hr = server->SetApplicationProperties(props); 
   if(FAILED(hr)) 
      goto error; 
 
error: 
   return hr; 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Media Streaming C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.