Com accessing a function\com dll access\ what to choose how to implement

Hi I am definitely new to win32 developing so if I ask sth so absurd please bear with it. I am
trying to access an ip camera, it is possible to do socket programming but this causes more
cpu/vmem usage than expected. The camera has a sdk came with it, it comes with only a dll
(not a lib or includes) and there are two samples one is accessing activeX provided in IE and
other one is a MFC application(which works more efficiently). In mfc app, there are a header
file and cpp file that communicates with possibly a com object (or a dll) (other files inherits
these or uses classes defined and create a dialog and window around it so they are
unimportant). What I want to do is to access a function mentioned in documentation and
which is also defined in the header file mentioned in the MFC project. First I tried dynamic
loading of dll and trying to load function(LoadLibrary, GetProcAddress) but did not worked.
Then I added files from MFC project to my win32 console app and changed linker options this
time I got an assertion problem with winocc.cpp during runtime(It triggered a breakpoint, I
was able to initiate class but when I called function it simply meets its end). My final hope is to
access function after reaching its interface in the COM object.So Can anyone provide me an
example of loading com object and interface (and if possible linker tweaks I am using VS2010)
(in registry 745395C8-D0E1-4227-8586-624CA9A10A8D corresponds to COM object
19722801-5830-4EC4-BD69-C3CF70776E0E) to interface I guess. My last hope is learning
how to use CoCreateInstance and learning what to import etc.).


Please help me out with this, knowing that I can reach a function but not being able to reach
is such a bothering thing. Sorry for long message



Here are the files I mentioned in MFC and some reports from dumpbin and pexplorer:
axismediacontrol.h many parts are removed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class CAxismediacontrol : public CWnd
{
protected:
	DECLARE_DYNCREATE(CAxismediacontrol)
public:
	CLSID const& GetClsid()
	{
		static CLSID const clsid
			= { 0x745395C8, 0xD0E1, 0x4227, { 0x85, 0x86, 0x62, 0x4C, 0xA9, 0xA1, 0xA, 0x8D } };
		return clsid;
	}
//.. crate functions was here
public:
// IAxisMediaControl
	void GetCurrentImage(long theFormat, VARIANT * theBuffer, long * theBufferSize)
	{
		static BYTE parms[] = VTS_I4 VTS_PVARIANT VTS_PI4 ;
		InvokeHelper(0x6e, DISPATCH_METHOD, VT_EMPTY, NULL, parms, theFormat, theBuffer, theBufferSize);
	}
};


and this is corresponding cpp axismediacontrol.cpp
1
2
3
#include "stdafx.h"
#include "axismediacontrol.h"
IMPLEMENT_DYNCREATE(CAxismediacontrol, CWnd)


Dumpbin /exports report of dll:
Dump of file c:\axismediacontrol.dll

File Type: DLL

  Section contains the following exports for AxisMediaControl.DLL

    00000000 characteristics
    4A5338D3 time date stamp Tue Jul 07 15:00:19 2009
        0.00 version
           1 ordinal base
          10 number of functions
          10 number of names

    ordinal hint RVA      name

          1    0 0005E70C CPlApplet
          2    1 00032612 CheckDShowVer
          3    2 00036C69 CheckMustRegisterDLL
          4    3 00032605 CheckPIII
          7    4 00005DD7 DllCanUnloadNow
          8    5 0000D47C DllGetClassObject
          9    6 0000FB4C DllRegisterServer
         10    7 0000FB5B DllUnregisterServer
          5    8 00033759 InstallMe
          6    9 00035221 UninstallMe

  Summary

        C000 .data
        1000 .data1
       2A000 .rdata
        D000 .reloc
       3A000 .rsrc
       C5000 .text


And Dll's registry info and information about interfaces provided by pe explorer

about interfaces
//AxisMediaControl 1.0 Type Library
//Version: 1.0
AXISMEDIACONTROLLib;
GUID = {A48F4EE0-B408-4376-B4C9-BC9CF6E16EBC};


//_IAxisMediaControlEvents Interface
Dispatch _IAxisMediaControlEvents;
GUID = {0997C74D-3ACE-4F31-99EC-47BC525E2382};
  //event fired when an error ocurrs
  function OnError(out theErrorCode: I4; out theErrorInfo: BSTR); stdcall;
  //others are removed

//AxisMediaControl Class
CoClass AxisMediaControl;
GUID = {745395C8-D0E1-4227-8586-624CA9A10A8D};

//IAxisMediaControl Interface
Dispatch IAxisMediaControl;
GUID = {19722801-5830-4EC4-BD69-C3CF70776E0E};
  function QueryInterface(riid: ^GUID; out ppvObj: ^^VOID); stdcall;
  function AddRef: UI4; stdcall;
  function Release: UI4; stdcall;
  function GetTypeInfoCount(out pctinfo: ^UINT); stdcall;
  function GetTypeInfo(itinfo: UINT; lcid: UI4; out pptinfo: ^^VOID); stdcall;
  function GetIDsOfNames(riid: ^GUID; rgszNames: ^^I1; cNames: UINT; lcid: UI4; out rgdispid: ^I4); stdcall;
  function Invoke(dispidMember: I4; riid: ^GUID; lcid: UI4; wFlags: UI2; pdispparams: 
^DISPPARAMS; out pvarResult: ^Variant; out pexcepinfo: ^EXCEPINFO; out puArgErr
: ^UINT); stdcall;
  //THE FUNCTION I NEED :) 
  function GetCurrentImage(theFormat: INT; out theBuffer: ^Variant; out theBufferSize: ^I4); stdcall;
  //others removed


registry info

HKCR
{
	AxisMediaControl.AxisMediaControl.1 = s 'AxisMediaControl Class'
	{
		CLSID = s '{745395C8-D0E1-4227-8586-624CA9A10A8D}'
		'Insertable'
	}
	AxisMediaControl.AxisMediaControl = s 'AxisMediaControl Class'
	{
		CLSID = s '{745395C8-D0E1-4227-8586-624CA9A10A8D}'
		CurVer = s 'AxisMediaControl.AxisMediaControl.1'
	}
	NoRemove CLSID
	{
		ForceRemove {745395C8-D0E1-4227-8586-624CA9A10A8D} = s 'AxisMediaControl Class'
		{
			ProgID = s 'AxisMediaControl.AxisMediaControl.1'
			VersionIndependentProgID = s 'AxisMediaControl.AxisMediaControl'
			ForceRemove 'Programmable'
			InprocServer32 = s '%MODULE%'
			{
				val ThreadingModel = s 'Apartment'
			}
			ForceRemove 'Control'
			ForceRemove 'Insertable'
			ForceRemove 'ToolboxBitmap32' = s '%MODULE%, 101'
			'MiscStatus' = s '0'
			{
			    '1' = s '131473'
			}
			'TypeLib' = s '{A48F4EE0-B408-4376-B4C9-BC9CF6E16EBC}'
			'Version' = s '1.0'
		}
	}
}


Volkan

Last edited on
Topic archived. No new replies allowed.