I am tring to communicate with a CoClass "GDAS" over COM from a Qt App with imported code from a from Studio Rad (Embarcadro) project (using the borland compiler and environment). The CoClass I need to access is contained in a locally created Borland Builder 6 App "GeDetekt.exe" as "GeDetekt.tlb"

I succesfully generated a namespace and the type wrappers GeDetekt.h and GeDetekt.cpp as explained http://doc.qt.io/qt-5/activeqt-container.html

by including

Qt Code:
  1. TYPELIBS = "C:\Users\Jennifer McClellant\Documents\Development\Opus Rs Alpha\GeDetekt.exe"
To copy to clipboard, switch view to plain text mode 

in my .pro file.

With GeDetekt.h now included on the Qt side I can now create and initialize the server:

Qt Code:
  1. int ComClient::connectToServer()
  2. {
  3. STARTUPINFOA sicomServer;
  4. PROCESS_INFORMATION picomServer;
  5. memset(&picomServer, 0, sizeof(picomServer));
  6. memset(&sicomServer, 0, sizeof(sicomServer));
  7.  
  8. sicomServer.dwFlags = STARTF_USESTDHANDLES;
  9. sicomServer.cb = sizeof(STARTUPINFO);
  10. sicomServer.lpReserved = nullptr;
  11. sicomServer.lpDesktop = nullptr;
  12. sicomServer.lpTitle = nullptr;
  13. sicomServer.cbReserved2 = 0;
  14. sicomServer.lpReserved2 = nullptr;
  15. sicomServer.dwFlags = 0;
  16.  
  17. std::string path = getPathToServer();
  18. std::replace(path.begin(), path.end(), '/', '\\');
  19. LPSTR str = static_cast<LPSTR>(const_cast<char*>(path.c_str()));
  20. int res = CreateProcessA(nullptr, str, nullptr, nullptr, false, 0,
  21. nullptr, nullptr, &sicomServer, //(s)tartup (i)nformation
  22. &picomServer);//(p)rocess (i)nformation, handle
  23.  
  24. if (res == 0)
  25. {
  26. QMessageBox msgBox;
  27. msgBox.setText("Unable to start COM Server.");
  28. msgBox.exec();
  29. errorExit("GetProcessId");
  30. }
  31.  
  32. for (int j = 0; j < 100; j++)//time to let COM server establish
  33. {
  34. Sleep(10);
  35.  
  36. if (!(j % 10))
  37. {
  38. QApplication::processEvents();
  39. }
  40. }
  41.  
  42. comServer = new GeDetekt::GDAS();
  43. isServerActive = true;
  44.  
  45. dataRetrievalTimer->start(timerCount);
  46. statusRetrievalTimer->start(timerCount);
  47.  
  48. return 1;
  49. }
  50.  
  51. std::string ComClient::getPathToServer()
  52. {
  53. std::string path = QDir::currentPath().toStdString() + "\\System";
  54. std::string iniFilePath = path + "\\" + "Sentinel.ini";
  55.  
  56. QSettings sentinelIni("Grandperspective", "Sentinel");
  57.  
  58. sentinelIni.setValue("GlobalSettings/OPUS_RS_PATH",
  59. "C:/Users/Jennifer McClellant/Documents/Development/Opus Rs Alpha/GeDetekt.exe");
  60.  
  61. std::string name = sentinelIni.value("GlobalSettings/OPUS_RS_PATH").toString().toStdString();
  62. std::string geDetektPath = name.empty()? std::string(): name;
  63. return geDetektPath;
  64. }
To copy to clipboard, switch view to plain text mode 

GeDetekt.exe starts, the server Api on client side (Qt side) seems to be initialised however when tring to run the methods e.g "ReturnStatus" on the server and access the returned data from the COM buffer, the QVariants are not valid (do not return data content).

Qt Code:
  1. void ComClient::getStatusFromServer()
  2. {
  3. if (!isServerActive)
  4. {
  5. return;
  6. }
  7.  
  8. statusRetrievalTimer->stop();
  9.  
  10. QVariant status;
  11. comServer->ReturnStatus(status);
  12.  
  13. VARIANT varStatus;
  14. QVariantToVARIANT(status, varStatus);
  15.  
  16. //check type: (array | real 8 byte (double))
  17. if (varStatus.vt == (VT_I1 | VT_ARRAY))
  18. {
  19. //--SafeArray: create with the VARIANT type
  20. SAFEARRAY *safeArr = V_ARRAY(&varStatus);
  21.  
  22. //--SafeArray: dimensions (bounds information)
  23. long lLbound = 0;
  24. long lUbound = 0;
  25. SafeArrayGetLBound(safeArr, 1, &lLbound);
  26. SafeArrayGetUBound(safeArr, 1, &lUbound);
  27. int amountStatusFlags = static_cast <int>(lUbound - lLbound + 1);
  28.  
  29. //--SafeArray: access the data
  30. bool *actualData;
  31. SafeArrayAccessData(safeArr, reinterpret_cast<void**>(&actualData));
  32.  
  33. serverStatus.clear();
  34. for (int i = 0; i < amountStatusFlags; i++)
  35. {
  36. serverStatus.push_back(static_cast<bool>(actualData[i]));
  37. }
  38.  
  39. SafeArrayUnaccessData(safeArr);
  40. }
  41. statusRetrievalTimer->start(timerCount);
  42. }
To copy to clipboard, switch view to plain text mode 

What could I have overseen? Please someone help.