Type Information For ASV
From Svg wiki
Here's a Microsoft Visual Studio C++ program to view the type information of the Adobe SVG Viewer control and its 'window' property. By copying and pasting the IDL displayed for the 'window' property and compiling with Microsoft MIDL compiler a .tlb file can be generated. The .tlb then can be #imported into your Visual Studio C++ .cpp file to obtain a wrapper that provides easy access the IDispatched properties and functions.
//Adobe SVG Window Interface viewer
//Verified under Visual Studio .Net
//Displays the type information found in the Adobe SVG control
//The type information for the SVGCtl is from the .tlb stored in
//npsvg3.dll. Type information is also available on the object gotten
//from the 'window' property on the SVG control.
//The sample displays the information in the TypeLib/Info viewer
//Richard L. Mahn
#define _WIN32_WINNT 0x0400
#include "tchar.h"
#include "comdef.h"
#include "objbase.h"
#import "npsvg3.dll"
//Or
//#import "progid:Adobe.SVGCtl"
//Begin IInterfaceViewer
//Provides Gui for ITypeLib and ITypeinfo interfaces and others
//Requires iViewers.dll used by OleView.exe (OLE/COM Object Viewer) to be installed
//Ref http://www.microsoft.com/com/resources/oleview.asp
//Also see http://www.microsoft.com/com/resources/OVI386.EXE
//and see http://msdn.microsoft.com/library/en-us/dnsamples/mfc_ole_oleview.exe
//must be in STA i.e. not COINIT_MULTITHREADED
//Also a treatAs CLSID
struct __declspec(uuid("64454F82-F827-11CE-9059-080036F12502")) CATID__OLEViewerInterfaceViewers;
struct __declspec(uuid("57EFBF49-4A8B-11CE-870B-0800368D2302")) ITypeLibViewer;
//Others for future reference
struct __declspec(uuid("7ce551ea-f85c-11ce-9059-080036f12502")) IUnknownViewer;
struct __declspec(uuid("7ce551eb-f85c-11ce-9059-080036f12502")) IPersistViewer;
struct __declspec(uuid("28d8aba0-4b78-11ce-b27d-00aa001f73c1")) IDataObjectViewer;
struct __declspec(uuid("d2af7a60-4c42-11ce-b27d-00aa001f73c1")) IDispatchViewer;
struct __declspec(uuid("28D8ABA0-4B78-11CE-B27D-00AA001F73C1")) IUDTViewer;
struct __declspec(uuid("D2AF7A60-4C42-11CE-B27D-00AA001F73C1")) IAutomationViewer;
struct __declspec(uuid("fc37e5ba-4a8e-11ce-870b-0800368d2302")) IInterfaceViewer: public IUnknown
{
virtual HRESULT __stdcall View(/* [in] */ HWND hParent, /* [in] */ REFIID riid, /* [in] */ IUnknown* pUnk) = 0;
};
_COM_SMARTPTR_TYPEDEF( IInterfaceViewer, __uuidof( IInterfaceViewer));
struct IInterfaceViewer_ITypeLibPtr: public IInterfaceViewerPtr
{
IInterfaceViewer_ITypeLibPtr(): IInterfaceViewerPtr( __uuidof( ITypeLibViewer)) {
}
};
//End IInterfaceViewer
//Begin HRX
//Provides error checking
//From http://faqchest.dynhost.com/msdn/DCOM/dcom-00/dcom-0011/dcom00111009_14783.html
class HRX {
private:
HRESULT m_hr;
public:
HRX() { // Default constructor sets HRESULT to success
m_hr = S_OK;
};
HRX(HRESULT hr) { // Initialise the HRESULT
operator=(hr); // call assignment operator so that we throw an error if (FAILED(hr))
}
HRESULT operator=(HRESULT hr) { // Set the HRESULT and immediately throw a _com_error on failure
m_hr = hr;
if (FAILED(hr)) {
throw _com_error(m_hr);
}
return m_hr;
}
operator HRESULT() const { // Enables the use of HRX as an HRESULT
return m_hr;
}
HRESULT* operator&() { // Enables the use of HRX as a pointer to an HRESULT
return &m_hr;
}
HRESULT Set(HRESULT hr) { // Set the HRESULT but do not throw on failure
return m_hr = hr;
}
};
//End HRX
inline ITypeInfoPtr Disp2Info( const IDispatchPtr &pDisp)
{
ITypeInfoPtr pTypeInfo;
HRX( pDisp->GetTypeInfo( 0, LOCALE_SYSTEM_DEFAULT, &pTypeInfo));
return pTypeInfo;
}
inline ITypeLibPtr Info2Lib( const ITypeInfoPtr &pTypeInfo)
{
ITypeLibPtr pTypeLib;
unsigned int Index;
HRX( pTypeInfo->GetContainingTypeLib( &pTypeLib, &Index));
return pTypeLib;
}
inline ITypeLibPtr Disp2Lib( const IDispatchPtr &pDisp)
{
return Info2Lib( Disp2Info( pDisp));
}
inline ITypeInfoPtr PCInfo2Info( const IProvideClassInfoPtr &pPCInfo)
{
ITypeInfoPtr pTypeInfo;
HRX( pPCInfo->GetClassInfo( &pTypeInfo));
return pTypeInfo;
}
inline ITypeLibPtr PCInfo2Lib( const IProvideClassInfoPtr &pPCInfo)
{
return Info2Lib( PCInfo2Info( pPCInfo));
}
int APIENTRY _tWinMain(
HINSTANCE /* hInstance */,
HINSTANCE /* hPrevInstance */,
LPTSTR /* lpCmdLine */,
int /* nCmdShow */)
{
HRX( CoInitialize( 0));
{ //Insures smart pointers are destructed before COM is Unititialized
SVGACTIVEXLib::ISVGControlPtr pSVG( __uuidof( SVGACTIVEXLib::SVGCtl));
//Or as an alternative
//SVGACTIVEXLib::ISVGControlPtr pSVG( _T("Adobe.SVGCtl"));
//Other useful interfaces
IPersistFilePtr pPFile = pSVG;
IPersistStreamInitPtr pPStream = pSVG;
IProvideClassInfoPtr pPCInfo = pSVG;
IDispatchPtr pDoc = pSVG->getSVGDocument();
IDispatchPtr pWin = pSVG->window;
IInterfaceViewer_ITypeLibPtr pViewer;
HRX( pViewer->View( 0, __uuidof( ITypeLib), PCInfo2Lib( pPCInfo)));
HRX( pViewer->View( 0, __uuidof( ITypeLib), Disp2Lib( pWin)));
}
CoUninitialize();
return 0;
}
RichardM Entivity.Com
