Uddie Posted January 22, 2018 Share Posted January 22, 2018 Hi, I have a demo version of DVBViewer Pro v 6.0.4. My C++ code for a COM interface is: #include "stdafx.h" #include <windows.h> #include <objbase.h> #include <comutil.h> #include <stdio.h> #include <time.h> #include <locale.h> #include "initguid.h" int _tmain(int argc, _TCHAR* argv[]) { HRESULT hr; VARIANT varRetVal; DISPID dispID; hr = CoInitialize( NULL ); if ( FAILED( hr ) ) { MessageBox( NULL, TEXT("CoInitialize"), TEXT("ERROR"), MB_OK ); return 2; } // Translate server ProgID into a CLSID. ClsidFromProgID // gets this information from the registry. // CLSID clsid; CLSIDFromProgID( L"DVBViewerServer.DVBViewer", & clsid ); IUnknown * pIUnknown; hr = GetActiveObject( clsid, NULL, & pIUnknown ); if ( FAILED( hr ) ) { MessageBox( NULL, TEXT("GetActiveObject"), TEXT("ERROR"), MB_OK ); return 2; } return 0; } I am getting the error message box: MessageBox( TEXT("GetActiveObject"), TEXT("ERROR"), MB_OK ); Can't figure out what's the problem :-( Anyone? Thanks in advance, Adi Quote Link to comment
hackbart Posted January 23, 2018 Share Posted January 23, 2018 I do something like this: const CLASS_DVBViewer: TGUID = '{D0B1ACAD-1190-4E6D-BD60-41DFA6A28E30}'; IID_IDVBViewer: TGUID = '{4CD4A1BF-7E90-4AA3-9C44-B36D78020FE8}'; var FDVBViewer: IDVBViewer3; function DVBViewer: IDVBViewer3; var Unknown: Iunknown; begin if FDVBViewer = nil then begin Unknown := nil; if GetActiveObject(CLASS_DVBViewer, nil, Unknown) <> MK_E_UNAVAILABLE then Unknown.QueryInterface(IID_IDVBViewer, FDVBViewer) else FDVBViewer := CreateComObject(CLASS_DVBViewer) as IDVBViewer3; end; Result := FDVBViewer; end; Quote Link to comment
Uddie Posted January 23, 2018 Author Share Posted January 23, 2018 Hi, Thanks but could you give me a C++ code? Quote Link to comment
Rayman Posted January 23, 2018 Share Posted January 23, 2018 (edited) vor 20 Stunden schrieb Uddie: Hi, I have a demo version of DVBViewer Pro v 6.0.4. I am getting the error message box: MessageBox( TEXT("GetActiveObject"), TEXT("ERROR"), MB_OK ); Can't figure out what's the problem :-( Did you do a step by step debugging to see where the error is? For example: Did you check whether CLSIDFromProgID( L"DVBViewerServer.DVBViewer", & clsid ); returns a valid clsid? I assume you are developing using Microsoft Visual C++? I recommend to use the Microsoft Tool "OLE COM Object Viewer" to inspect the DVBViewer COM Library. From there you can generate .h Header and clsid files as stubs for your DVBViewer class that make the development easier. You might get some hints from these two threads, these are in German but there are a lot of code samples and downloads that might help: http://www.DVBViewer.tv/forum/topic/49926-howto-DVBViewer-entwicklung-in-c/ http://www.DVBViewer.tv/forum/topic/33691-c-anfang/ Furthermore I see that you are using the DEMO version of DVBViewer, I don't know whether this is fully functional regarding the COM interface, @hackbart ? Edited January 23, 2018 by Rayman Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.