Tricky!! VB.NET counterpart of CLSIDFromProgID and CoCreateInstance
-
Hello, I have some (more than once) COM-Servers (in different DLL's) and each of them implements the same Interface. Only what I know is the InterfaceName and the ProgID of the COM-Server. How can I instanciate a COM-Object in VB.NET with this informations? I C/C++ it looks like:
HRESULT hr = CLSIDFromProgID (ProgID), &clsid); hr = CoCreateInstance (clsid, NULL, CLSCTX_INPROC_SERVER, IID_IInterfaceName, (void **) &m_pCOMSmartPtr); \\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_) -
Hello, I have some (more than once) COM-Servers (in different DLL's) and each of them implements the same Interface. Only what I know is the InterfaceName and the ProgID of the COM-Server. How can I instanciate a COM-Object in VB.NET with this informations? I C/C++ it looks like:
HRESULT hr = CLSIDFromProgID (ProgID), &clsid); hr = CoCreateInstance (clsid, NULL, CLSCTX_INPROC_SERVER, IID_IInterfaceName, (void **) &m_pCOMSmartPtr); \\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)Does something like this work for you?
Dim t As Type = Type.GetTypeFromProgID("_progID_") Dim retVal As Object retVal = Activator.CreateInstance(t)
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Does something like this work for you?
Dim t As Type = Type.GetTypeFromProgID("_progID_") Dim retVal As Object retVal = Activator.CreateInstance(t)
Dave Kreskowiak Microsoft MVP - Visual Basic
Hello Dave, Yes this works fine. Thank you. Regards Stephan
\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_) -
Hello Dave, Yes this works fine. Thank you. Regards Stephan
\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)No problem! :-D
Dave Kreskowiak Microsoft MVP - Visual Basic