How to instantiate serverx in another ActiveX?


How to instantiate serverx in another ActiveX?

Author
Message
madkoala
View Quick Profile

Supreme Being
Supreme Being (1.2K reputation)Supreme Being (1.2K reputation)Supreme Being (1.2K reputation)Supreme Being (1.2K reputation)Supreme Being (1.2K reputation)Supreme Being (1.2K reputation)Supreme Being (1.2K reputation)Supreme Being (1.2K reputation)Supreme Being (1.2K reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 8, Visits: 31
I want to know how to instantiate in another activex (with Visual C++).
Here's the code snippet.

in .h file: 

#import "..\Modules\scvncsrvx.dll" named_guids rename_namespace("SRVX")

class CServerAxCtrl : public COleControl
{
   DECLARE_DYNCREATE(CServerAxCtrl)

// Constructor
public:
   CServerAxCtrl();



......... omitted .........

// Dispatch and event IDs
public:
   enum {
      dispidInitializeComponent = 1L
   };
protected:
   VARIANT_BOOL InitializeComponent(void);

protected:
   VARIANT_BOOL _SetServerProperties(void);
   VARIANT_BOOL _RunServerDirect(void);
   VARIANT_BOOL _RunServerRepeater(LPCTSTR lpszRepeaterAddr, LONG lServerPort, LPCTSTR lpszCode);

protected:
   CComPtr<SRVX::ISc_ServerX> m_pServerX;
   bool m_bInit;
};



in .cpp file:

VARIANT_BOOL CServerAxCtrl::InitializeComponent(void)
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());

   VARIANT_BOOL vbResult = VARIANT_FALSE;

   try
   {
      CHK_HR(m_pServerX.CoCreateInstance(__uuidof(SRVX::__ServerX)));
      if (_SetServerProperties() == VARIANT_FALSE)
      {
         :TonguerintDbgMsg(TEXT("[%s][%d][ERROR] Failed to set server properties."),
            __FUNCTION__, __LINE__);
         m_bInit = false;
      }
      else
      {
         m_bInit = true;
         vbResult = VARIANT_TRUE;
      }
   }

   catch (::_com_error& ex)
   {
      :TonguerintDbgMsg(TEXT("[%s][%d] COM exception caught: [%s]"),
         __FUNCTION__, __LINE__, ex.ErrorMessage());
      m_bInit = false;
      vbResult = VARIANT_FALSE;
   }
   
   return vbResult;
}

But it doesn't work. Exception "Class not registered" occurs.
Is it possible that ServerX works without user interface?
If possible, please let me know.

And also if you can, please send me a sample of ServerX with Visual C++.
Thank you.
Yury Averkiev (s-code)
View Quick Profile

Supreme Being
Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)

Group: Administrators
Last Active: 3 days ago @ 6:45 PM
Posts: 1.9K, Visits: 3.5K
But it doesn't work. Exception "Class not registered" occurs.

Is your application built as 64-bit or Any CPU on a 64-bit computer? ServerX is a 32-bit ActiveX and this could be the reason why you are getting the "Class not registered" error, because a 64-bit application cannot instantiate 32-bit ActiveX controls.

Is it possible that ServerX works without user interface?

I haven’t tried this, but chances are, that if you don’t want to show any UI, you would need to create a hidden window and add use it as a parent to window create a ServerX control instance.

http://www.s-code.com/App_Themes/Default/images/blue_line.gif
Kindest Regards,
SmartCode Solutions Support


Similar Topics


Reading This Topic