Jump to content

GetActiveObject error


Uddie

Recommended Posts

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

Link to comment

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;

 

Link to comment
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 by Rayman
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...