Esempio n. 1
1
HRESULT CComModule::RegisterTypeLib()
{
	USES_CONVERSION;
	_ASSERTE(m_hInst != NULL);
	TCHAR szModule[_MAX_PATH+4];
	TCHAR szDir[_MAX_PATH];
	GetModuleFileName(GetTypeLibInstance(), szModule, _MAX_PATH);
	CComPtr<ITypeLib> pTypeLib;
	HRESULT hr = LoadTypeLib(T2OLE(szModule), &pTypeLib);
	if (!SUCCEEDED(hr))
	{
		// typelib not in module, try <module>.tlb instead
		LPTSTR lpszExt = szModule + lstrlen(szModule);
		for (LPTSTR lpsz = szModule; *lpsz != '\0'; lpsz = CharNext(lpsz))
		{
			if (*lpsz == '.')
				lpszExt = lpsz;
		}
		_ASSERTE(lpszExt != NULL);
		lstrcpy(lpszExt, _T(".tlb"));
		hr = LoadTypeLib(T2OLE(szModule), &pTypeLib);
	}
	if (SUCCEEDED(hr))
	{
		int nLen = lstrlen(szModule) - AtlGetFileName(szModule, NULL, 0);
		lstrcpy(szDir, szModule);
		szDir[nLen] = 0;
		return ::RegisterTypeLib(pTypeLib, T2OLE(szModule), T2OLE(szDir));
	}
	return S_FALSE;
}
Esempio n. 2
0
extern "C" BOOL RegisterComServers (char *modulePath)
{
	BOOL ret = TRUE;
	wchar_t mainModule[1024], formatModule[1024];
	CComPtr<ITypeLib> tl, tl2;

	wsprintfW (mainModule, L"%hsGostCrypt.exe", modulePath);
	wsprintfW (formatModule, L"%hsGostCrypt Format.exe", modulePath);

	UnRegisterTypeLib (LIBID_GostCryptMainCom, GST_MAIN_COM_VERSION_MAJOR, GST_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32);
	UnRegisterTypeLib (LIBID_GostCryptFormatCom, GST_FORMAT_COM_VERSION_MAJOR, GST_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32);

	wchar_t setupModule[MAX_PATH];
	GetModuleFileNameW (NULL, setupModule, sizeof (setupModule) / sizeof (setupModule[0]));

	CRegObject ro;
	HRESULT r;

	if (!SUCCEEDED (r = ro.FinalConstruct ())
		|| !SUCCEEDED (r = ro.AddReplacement (L"MAIN_MODULE", mainModule))
		|| !SUCCEEDED (r = ro.AddReplacement (L"FORMAT_MODULE", formatModule))
		|| !SUCCEEDED (r = ro.ResourceRegister (setupModule, IDR_COMREG, L"REGISTRY"))
		|| !SUCCEEDED (r = LoadTypeLib (mainModule, &tl))
		|| !SUCCEEDED (r = RegisterTypeLib (tl, mainModule, 0))
		|| !SUCCEEDED (r = LoadTypeLib (formatModule, &tl2))
		|| !SUCCEEDED (r = RegisterTypeLib (tl2, formatModule, 0)))
	{
		MessageBox (MainDlg, _com_error (r).ErrorMessage(), GST_APP_NAME, MB_ICONERROR);
		ret = FALSE;
	}

	ro.FinalRelease ();
	return ret;
}
Esempio n. 3
0
// load an external type library
VOID FAR LoadExtTypeLib
(
    LPIMPORTLIB lpImpLib
)
{
    ITypeLib FAR* lptlib;
    HRESULT res;
    BSTR bstrName;

    SETITEMCUR(lpImpLib->lpszFileName);

    // get * to ITypeLib interface
    CHECKRESULT(LoadTypeLib(ToW(lpImpLib->lpszFileName), &lptlib));
    lpImpLib->lptlib = lptlib;

    // get name of this library
    CHECKRESULT(lptlib->GetDocumentation(-1, &bstrName, NULL, NULL, NULL));
    // copy library name from the BSTR
    lpImpLib->lpszLibName = _fstrdup(ToA(bstrName));

    SysFreeString(bstrName);		// free the BSTR

    // get * to ITypeComp interface
    CHECKRESULT(lptlib->GetTypeComp(&(lpImpLib->lptcomp)));
    
    // get library attributes
    CHECKRESULT(lptlib->GetLibAttr(&(lpImpLib->lptlibattr)));

}
Esempio n. 4
0
static void ref_count_test(LPCWSTR type_lib)
{
    ITypeLib *iface;
    ITypeInfo *iti1, *iti2;
    HRESULT hRes;
    int ref_count;

    trace("Loading type library\n");
    hRes = LoadTypeLib(type_lib, &iface);
    ok(hRes == S_OK, "Could not load type library\n");
    if(hRes != S_OK)
        return;

    hRes = ITypeLib_GetTypeInfo(iface, 1, &iti1);
    ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
    ok(ref_count=ITypeLib_Release(iface) > 0, "ITypeLib destroyed while ITypeInfo has back pointer\n");
    if(!ref_count)
        return;

    hRes = ITypeLib_GetTypeInfo(iface, 1, &iti2);
    ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
    ok(iti1 == iti2, "ITypeLib_GetTypeInfo returned different pointers for same indexes\n");

    ITypeLib_AddRef(iface);
    ITypeInfo_Release(iti2);
    ITypeInfo_Release(iti1);
    ok(ITypeLib_Release(iface) == 0, "ITypeLib should be destroyed here.\n");
}
Esempio n. 5
0
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
{
    HRESULT hres;

    if (!typelib) {
        ITypeLib *tl;

        static const WCHAR vbscript_dll1W[] = {'v','b','s','c','r','i','p','t','.','d','l','l','\\','1',0};

        hres = LoadTypeLib(vbscript_dll1W, &tl);
        if(FAILED(hres)) {
            ERR("LoadRegTypeLib failed: %08x\n", hres);
            return hres;
        }

        if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
            ITypeLib_Release(tl);
    }

    if(!typeinfos[tid]) {
        ITypeInfo *ti;

        hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
        if(FAILED(hres)) {
            ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
            return hres;
        }

        if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
            ITypeInfo_Release(ti);
    }

    *typeinfo = typeinfos[tid];
    return S_OK;
}
Esempio n. 6
0
/////////////////////////////////////////////////////////////////////////////
// SAX message handlers
BOOL SAX::OnInitDialog() 
{
   CDialog::OnInitDialog();
   
   ITypeLib **pptLib = new (ITypeLib *);
   CString tlb, path;
   tlb = path = getApp().getCamcadExeFolderPath();
   tlb += "camcad.tlb";

   if (LoadTypeLib(tlb.AllocSysString(), pptLib) != S_OK || RegisterTypeLib(*pptLib, tlb.AllocSysString(), path.AllocSysString()) != S_OK)
      MessageBox("Type libraries not avalible for browsing.");

   delete (pptLib);

//#Reference {F8DE4B05-FBC2-11D1-BA40-0080ADB36DBB}#1.0#0#C:\camcad\WinDebug\Camcad.tlb#CAMCAD
   dispatch = NULL;
// HRESULT hr = __CreateObject(OLESTR("CAMCAD.Application"), &dispatch);
// if (FAILED(hr))
// {
      m_sbpro.SetCode("Sub Main\r\n\tDim objCAMCAD\r\n\tSet objCAMCAD = CreateObject(\"CAMCAD.Application\")\r\n\r\n\t'example\r\n\t'objCAMCAD.ZoomLevel 2, 1\r\n\r\nEnd Sub");
      m_sbpro.AddExtension("{F8DE4B05-FBC2-11D1-BA40-0080ADB36DBB}#1.0#0#", NULL);
// }
// else
//    m_sbpro.AddExtension("", dispatch);

   m_sbpro.SetDefaultDataType("CAMCAD.Application");
   m_sbpro.SetHighlightExtension(0x804000);
   
   
   return TRUE;  // return TRUE unless you set the focus to a control
                 // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 7
0
// Register this browser helper object. This method is invoked by regsrv32.exe
// during installation to set the Windows Registry keys that tell Internet
// Explorer that we are a Browser Helper Object server.
HRESULT __stdcall DllRegisterServer(void)
{
    HKEY hkBHO = NULL, hkVerity = NULL;
    LPTYPELIB pTypeLib = NULL;
    HRESULT hr;

    WCHAR lpzLibrary[MAX_PATH];
    LPTSTR lpzControlName   = _T("Verity Controller"); 
    LPTSTR lpzClassKey      = _T("CLSID\\") CLSID_VERITY;
    LPTSTR lpzContextKey    = _T("CLSID\\{7CD57D42-C553-4B82-A52A-513082F57EE0}");
    LPTSTR lpzOnDocumentKey = _T("CLSID\\{42939237-42F0-4E3F-818E-FA63E4EB5A82}");
    LPTSTR lpzBHOKey        = _T("Software\\Microsoft\\Windows\\CurrentVersion\\")
                              _T("Explorer\\Browser Helper Objects");

    if (!GetModuleFileNameW(hDllModule, lpzLibrary, MAX_PATH)) {
        hr = E_FAIL;
        goto exit;
    }
    if (hr = AddClass(L"CLSID\\" CLSID_VERITY, L"Verity Controller", lpzLibrary))
    {
        goto exit;
    }

    if (hr = AddClass(L"CLSID\\{73C6AB50-2BEE-4DC0-AB1C-910C255D1C23}", L"Verity ActiveScriptSite", lpzLibrary))
    {
        goto exit;
    }
    if (hr = AddClass(L"CLSID\\{42939237-42F0-4E3F-818E-FA63E4EB5A82}", L"Verity OnDocument Handler", lpzLibrary))
    {
        goto exit;
    }

    if (hr = AddClass(L"CLSID\\{7CD57D42-C553-4B82-A52A-513082F57EE0}", L"Verity Script Context", lpzLibrary))
    {
        goto exit;
    }

    if (hr = CreateKey(HKEY_LOCAL_MACHINE, lpzBHOKey, &hkBHO)) goto exit;
    if (hr = CreateKey(hkBHO, CLSID_VERITY, &hkVerity)) goto exit;
    if (hr = SetString(hkVerity, NULL, lpzControlName)) goto exit;

    if (hr = LoadTypeLib(lpzLibrary, &pTypeLib)) goto exit;
    if (hr = RegisterTypeLib(pTypeLib, lpzLibrary, NULL)) goto exit;
exit:
    if (hkBHO)
    {
        RegCloseKey(hkBHO);
    }
    if (hkVerity)
    {
        RegCloseKey(hkVerity);
    }
    if (pTypeLib)
    {
        pTypeLib->lpVtbl->Release(pTypeLib);
    }
    return hr;
}
Esempio n. 8
0
BOOL AFXAPI AfxOleRegisterTypeLib(HINSTANCE hInstance, REFGUID tlid,
	LPCTSTR pszFileName, LPCTSTR pszHelpDir)
{
	USES_CONVERSION;

	BOOL bSuccess = FALSE;
	CString strPathName;
	TCHAR *szPathName = strPathName.GetBuffer(_MAX_PATH);
	::GetModuleFileName(hInstance, szPathName, _MAX_PATH);
	strPathName.ReleaseBuffer();
	LPTYPELIB ptlib = NULL;

	// If a filename was specified, replace final component of path with it.
	if (pszFileName != NULL)
	{
		int iBackslash = strPathName.ReverseFind('\\');
		if (iBackslash != -1)
			strPathName = strPathName.Left(iBackslash+1);
		strPathName += pszFileName;
	}

	if (SUCCEEDED(LoadTypeLib(T2COLE(strPathName), &ptlib)))
	{
		ASSERT_POINTER(ptlib, ITypeLib);

		LPTLIBATTR pAttr;
		GUID tlidActual = GUID_NULL;

		if (SUCCEEDED(ptlib->GetLibAttr(&pAttr)))
		{
			ASSERT_POINTER(pAttr, TLIBATTR);
			tlidActual = pAttr->guid;
			ptlib->ReleaseTLibAttr(pAttr);
		}

		// Check that the guid of the loaded type library matches
		// the tlid parameter.
		ASSERT(IsEqualGUID(tlid, tlidActual));

		if (IsEqualGUID(tlid, tlidActual))
		{
			// Register the type library.
			if (SUCCEEDED(RegisterTypeLib(ptlib,
					T2OLE((LPTSTR)(LPCTSTR)strPathName), T2OLE((LPTSTR)pszHelpDir))))
				bSuccess = TRUE;
		}

		RELEASE(ptlib);
	}
	else
	{
		TRACE1("Warning: Could not load type library from %s\n", (LPCTSTR)strPathName);
	}

	return bSuccess;
}
Esempio n. 9
0
HRESULT CCmdTarget::GetTypeInfoOfGuid(LCID lcid, REFGUID guid,
	LPTYPEINFO* ppTypeInfo)
{
	USES_CONVERSION;

	AfxLockGlobals(CRIT_TYPELIBCACHE);

	HRESULT hr = TYPE_E_CANTLOADLIBRARY;
	CTypeLibCache* pTypeLibCache = GetTypeLibCache();
	LPTYPELIB pTypeLib = NULL;

	// If type info is already cached, just return it.
	if (pTypeLibCache->LookupTypeInfo(lcid, guid, ppTypeInfo))
	{
		hr = S_OK;
	}
	else
	{
		// If type library isn't already cached, try to locate it.
		if (!pTypeLibCache->Lookup(lcid, &pTypeLib))
		{
			// First, try getting the subclass to load the type library
			// (normally this goes through LoadRegTypeLib).

			if (FAILED(GetTypeLib(lcid, &pTypeLib)))
			{
				AFX_MANAGE_STATE(m_pModuleState);

				// If that failed, try loading the type library from our own
				// resources.

				TCHAR szPath[_MAX_PATH];
				GetModuleFileName(AfxGetInstanceHandle(), szPath, _MAX_PATH);

				if (FAILED(LoadTypeLib(T2COLE(szPath), &pTypeLib)))
					pTypeLib = NULL;
			}

			pTypeLibCache->Cache(lcid, pTypeLib);
		}

		// If we got a type library, extract the requested type info.
		if (pTypeLib != NULL)
		{
			hr = pTypeLib->GetTypeInfoOfGuid(guid, ppTypeInfo);
			pTypeLib->Release();
			pTypeLibCache->CacheTypeInfo(lcid, guid, *ppTypeInfo);
		}
	}

	AfxUnlockGlobals(CRIT_TYPELIBCACHE);

	return hr;
}
Esempio n. 10
0
void RegTypeLib(TCHAR *file)
{
#ifdef _UNICODE
 ITypeLib* tlib;
 if (SUCCEEDED(LoadTypeLib(file, &tlib))) {
   RegisterTypeLib(tlib, file, NULL);
   tlib->lpVtbl->Release(tlib);
 }
#else
  WCHAR wfile[STR_SIZE];

  if (MultiByteToWideChar(CP_ACP, 0, file, -1, wfile, STR_SIZE) != 0)
  {
    ITypeLib* tlib;
    if (SUCCEEDED(LoadTypeLib(wfile, &tlib))) {
      RegisterTypeLib(tlib, wfile, NULL);
      tlib->lpVtbl->Release(tlib);
    }
  }
#endif
}
Esempio n. 11
0
void RegTypeLib(char *file)
{
    WCHAR wfile[STR_SIZE];

    if (MultiByteToWideChar(CP_ACP, 0, file, -1, wfile, STR_SIZE) != 0)
    {
        ITypeLib* tlib;
        if (SUCCEEDED(LoadTypeLib(wfile, &tlib))) {
            RegisterTypeLib(tlib, wfile, NULL);
            tlib->lpVtbl->Release(tlib);
        }
    }
}
Esempio n. 12
0
HRESULT CExtendedControl::Init( REFCLSID clsidControl,
   CTestContainer98Item* pItem )
{
   HRESULT hResult;
   ITypeLibPtr pTypeLib;
   LPOLESTR pszModuleO;
   TCHAR szModule[MAX_PATH];
   CString strTLBPath;

   ASSERT( m_pItem != NULL );
   ASSERT( m_pControl == NULL );

   hResult = CoCreateInstance( clsidControl, (IUnknown*)this,
	  CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, IID_IUnknown, (void**)&m_pControl );
   if( FAILED( hResult ) )
   {
	  return( hResult );
   }

   m_pInnerDispatch = m_pControl;
   if( m_pInnerDispatch == NULL )
   {
	  return( E_NOINTERFACE );
   }
   Release();  // Artificially release because we QI'd the aggregate.

   GetModuleFileName( NULL, szModule, MAX_PATH );
   strTLBPath = szModule;
   strTLBPath += _T( "\\2" );  // Load the second TLB from the executable

   pszModuleO = strTLBPath.AllocSysString();
   hResult = LoadTypeLib( pszModuleO, &pTypeLib );
   if( FAILED( hResult ) )
   {
	  TCTrace( TRACELEVEL_NORMAL,
		 "Failed to load typelib for extended control\n" );
	  return( hResult );
   }

   hResult = pTypeLib->GetTypeInfoOfGuid( __uuidof( ITCExtendedControl ),
	  &m_pTypeInfo );
   if( FAILED( hResult ) )
   {
	  return( hResult );
   }

   m_pItem = pItem;
   m_pView = m_pItem->GetDocument()->GetView();

   return( S_OK );
}
Esempio n. 13
0
JNIEXPORT jlong JNICALL Java_com4j_Native_loadTypeLibrary(
	JNIEnv* env, jclass __unused__, jstring _name ) {

	JString name(env,_name);
	ITypeLib* pLib=NULL;

	HRESULT hr = LoadTypeLib(name,&pLib);
	if(FAILED(hr)) {
		error(env,__FILE__,__LINE__,hr,"LoadTypeLib failed");
		return 0;
	}
	
	return reinterpret_cast<jlong>(typelib::CTypeLib::get(pLib));
}
Esempio n. 14
0
	STDAPI DllRegisterServer(void) {
		WCHAR path[MAX_PATH];
		GetModuleFileName(g_hMod, path, MAX_PATH);
		RegisterServer(CLSID_Book, L"BookLib.Book", 1);
		RegisterServer(CLSID_Chapter, L"BookLib.Chapter", 1);
		RegisterServer(CLSID_Section, L"BookLib.Section", 1);
		ITypeLib* typeLib = nullptr;
		auto hr = LoadTypeLib(path, &typeLib);
		if (hr != S_OK) {
			return hr;
		}
		hr = RegisterTypeLib(typeLib, path, NULL);
		return hr;
	}
Esempio n. 15
0
int _tmain(int argc, _TCHAR* argv[]){
	const OLECHAR szFile[] = TEXT("testmidl.tlb");//TEXT("D:\\Desktop\\COM_Type_Library_Viewer\\COM_Type_Library_Viewer\\testmidl.tlb");
	ITypeLib* p_tlib;  
	ITypeInfo* pTinfo;
	HRESULT hr = LoadTypeLib(szFile, &p_tlib); 
	//hr = p_tlib->GetTypeInfoOfGuid(IID_ISum, &pTinfo);//Succeeded
	//hr = p_tlib->GetTypeInfoOfGuid(LIBID_Component, &pTinfo);
	hr = p_tlib->GetTypeInfoOfGuid(CLSID_InsideCOM, &pTinfo);//Succeeded!!
	hr = PrintTInfo(pTinfo, 0);
	pTinfo->Release();
	p_tlib->Release();
	std::getchar();
	return 1;
}
Esempio n. 16
0
template <class T> SepaControlDispatch<T>::SepaControlDispatch()
:SepaControlUnknown()
{
	m_pTypeLib = NULL;
	m_pTypeInfo = NULL;

	if (LoadTypeLib(g_lpszDllPath, &m_pTypeLib) == S_OK)
	{
		if (m_pTypeLib->GetTypeInfoOfGuid(__uuidof(T), &m_pTypeInfo) != S_OK)
		{
			m_pTypeLib->Release();
			m_pTypeLib = NULL;
		}
	}
}
Esempio n. 17
0
extern "C" BOOL RegisterComServers (char *modulePath)
{
	BOOL ret = FALSE;
	wchar_t mainModule[1024], formatModule[1024];
	CComPtr<ITypeLib> tl, tl2;

	wsprintfW (mainModule, L"%hsTrueCrypt.exe", modulePath);
	wsprintfW (formatModule, L"%hsTrueCrypt Format.exe", modulePath);

	UnRegisterTypeLib (LIBID_TrueCryptMainCom, 1, 0, 0, SYS_WIN32);
	UnRegisterTypeLib (LIBID_TrueCryptFormatCom, 1, 0, 0, SYS_WIN32);

	CRegObject ro;
	ro.FinalConstruct ();

	ro.AddReplacement (L"MAIN_MODULE", mainModule);
	ro.AddReplacement (L"FORMAT_MODULE", formatModule);

	wchar_t setupModule[MAX_PATH];
	GetModuleFileNameW (NULL, setupModule, sizeof (setupModule) / sizeof (setupModule[0]));
	if (ro.ResourceRegister (setupModule, IDR_COMREG, L"REGISTRY") != S_OK)
		goto error;

	if (LoadTypeLib (mainModule, &tl) != S_OK
		|| RegisterTypeLib (tl, mainModule, 0) != S_OK)
		goto error;

	if (LoadTypeLib (formatModule, &tl2) != S_OK
		|| RegisterTypeLib (tl2, formatModule, 0) != S_OK)
		goto error;

	ret = TRUE;
error:
	ro.FinalRelease ();
	return ret;
}
Esempio n. 18
0
STDAPI DllRegisterServer()
{
	HRESULT hr = AMovieDllRegisterServer2(TRUE);

	// register type library
	WCHAR achFileName[MAX_PATH];
	GetModuleFileNameW(g_hInst, achFileName, MAX_PATH);
	ITypeLib* pTypeLib;
	LoadTypeLib(achFileName, &pTypeLib);
	if (pTypeLib)
	{
		RegisterTypeLib(pTypeLib, achFileName, NULL);
		pTypeLib->Release();
	}

	return hr;
}
Esempio n. 19
0
HRESULT UnRegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex)
{
	CComBSTR bstrPath;
	CComPtr<ITypeLib> pTypeLib;
	HRESULT hr = LoadTypeLib(hInstTypeLib, lpszIndex, &bstrPath, &pTypeLib);
	if (SUCCEEDED(hr))
	{
		TLIBATTR* ptla;
		hr = pTypeLib->GetLibAttr(&ptla);
		if (SUCCEEDED(hr))
		{
			hr = ::UnRegisterTypeLib(ptla->guid, ptla->wMajorVerNum, ptla->wMinorVerNum, ptla->lcid, ptla->syskind);
			pTypeLib->ReleaseTLibAttr(ptla);
		}
	}
	return hr;
}
Esempio n. 20
0
HRESULT ComRegistration::registerTypeLib( HMODULE hInst )
{
	//get the qualified path of the dll calling this function
	WCHAR modulePath[MAX_PATH];
	GetModuleFileName( hInst, modulePath, MAX_PATH );

	ITypeLib *ptlib;

	HRESULT hr = LoadTypeLib( modulePath, &ptlib );
	if( !SUCCEEDED(hr) ) return hr;

	hr = RegisterTypeLib( ptlib, modulePath, NULL );
	
	ptlib->Release();

	return hr;
}
Esempio n. 21
0
File: main.c Progetto: Kelimion/wine
static BOOL load_typelib(void)
{
    ITypeLib *typelib;
    HRESULT hres;

    static const WCHAR wscript_exeW[] = {'w','s','c','r','i','p','t','.','e','x','e',0};

    hres = LoadTypeLib(wscript_exeW, &typelib);
    if(FAILED(hres))
        return FALSE;

    hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IHost, &host_ti);
    if(SUCCEEDED(hres))
        hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IArguments2, &arguments_ti);

    ITypeLib_Release(typelib);
    return SUCCEEDED(hres);
}
Esempio n. 22
0
static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
        ITypeInfo **ppTInfo)
{
    ITypeLib *typelib;
    HRESULT hres;

    static const WCHAR mshtml_tlbW[] = {'m','s','h','t','m','l','.','t','l','b',0};

    ok(!iTInfo, "iTInfo = %d\n", iTInfo);
    ok(!lcid, "lcid = %x\n", lcid);

    hres = LoadTypeLib(mshtml_tlbW, &typelib);
    ok(hres == S_OK, "LoadTypeLib failed: %08x\n", hres);

    hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IHTMLElement, ppTInfo);
    ok(hres == S_OK, "GetTypeInfoOfGuid failed: %08x\n", hres);

    ITypeLib_Release(typelib);
    return S_OK;
}
Esempio n. 23
0
// @pymethod <o PyITypeLib>|pythoncom|LoadTypeLib|Loads a registered type library.
PyObject *pythoncom_loadtypelib(PyObject *self, PyObject *args)
{
	PyObject *obName;
	// @pyparm string|libFileName||The path to the file containing the type information.
	if (!PyArg_ParseTuple(args, "O:LoadTypeLib", &obName))
		return NULL;

	BSTR bstrName;
	if (!PyWinObject_AsBstr(obName, &bstrName))
		return NULL;

	ITypeLib *ptl;
	PY_INTERFACE_PRECALL;
	SCODE sc = LoadTypeLib(bstrName, &ptl);
	PyWinObject_FreeBstr(bstrName);
	PY_INTERFACE_POSTCALL;
	if (FAILED(sc))
		return PyCom_BuildPyException(sc);

	return PyCom_PyObjectFromIUnknown(ptl, IID_ITypeLib);
}
Esempio n. 24
0
ITypeLib *get_msi_typelib( LPWSTR *path )
{
    EnterCriticalSection( &MSI_typelib_cs );

    if (!msi_typelib)
    {
        TRACE("loading typelib\n");

        if (GetModuleFileNameW( msi_hInstance, msi_path, MAX_PATH ))
            LoadTypeLib( msi_path, &msi_typelib );
    }

    LeaveCriticalSection( &MSI_typelib_cs );

    if (path)
        *path = msi_path;

    if (msi_typelib)
        ITypeLib_AddRef( msi_typelib );

    return msi_typelib;
}
Esempio n. 25
0
HRESULT 
hippoLoadTypeInfo(const WCHAR *libraryName, ...)
{
    HippoPtr<ITypeLib> typeLib;
    va_list vap;
    HRESULT hr;            

    HMODULE module = GetModuleHandle(libraryName);
    if (!module)
        return E_FAIL;

    WCHAR moduleFile[MAX_PATH];
    DWORD length = GetModuleFileName(module, moduleFile, MAX_PATH);
    if (length == 0 || length > MAX_PATH - 1)
        return E_FAIL;

    va_start(vap, libraryName);
    clearArgs(vap);
    va_end(vap);

    hr = LoadTypeLib(moduleFile, &typeLib);
    if (FAILED(hr))
        goto out;

    va_start(vap, libraryName);
    hr = loadTypeInfoFromTypelib(typeLib, vap);
    va_end(vap);

out:
    if (FAILED(hr)) {
        va_start(vap, libraryName);
        freeArgs(vap);
        va_end(vap);

        hippoDebugDialog(L"Failed to load type info from %ls (%x)", libraryName, hr);
    }

    return hr;
}
Esempio n. 26
0
HRESULT RegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex)
{
	CComBSTR bstrPath;
	CComPtr<ITypeLib> pTypeLib;
	HRESULT hr = LoadTypeLib(hInstTypeLib, lpszIndex, &bstrPath, &pTypeLib);
	if (SUCCEEDED(hr))
	{
		OLECHAR szDir[MAX_PATH];
		ocscpy_s(szDir, MAX_PATH,bstrPath);
		// If index is specified remove it from the path
		if (lpszIndex != NULL)
		{
			size_t nLenPath = ocslen(szDir);
			size_t nLenIndex = ocslen(lpszIndex);
			if (memcmp(szDir + nLenPath - nLenIndex, lpszIndex, nLenIndex) == 0)
				szDir[nLenPath - nLenIndex] = 0;
		}
		szDir[GetDirLen(szDir)] = 0;
		hr = ::RegisterTypeLib(pTypeLib, bstrPath, szDir);
	}
	return hr;
}
Esempio n. 27
0
// rayk - need to ensure that this object supports IPersistStream
BOleFont::BOleFont (BOleClassManager *pCF, IBUnknownMain * pO) :
        BOleComponent (pCF, pO),
        weight (FW_NORMAL),            modified (FALSE),
        charSet (DEFAULT_CHARSET),     style (fsBold),
        pTI (NULLP),                   pTL (NULLP),
        pF (NULLP),                    pEventList (NULLP),
        cyLogical (1),                 cyHimetric (1),
        bstrName (SysAllocString (OLESTR ("Arial")))
//        bstrName (SysAllocString (OLESTR ("MS Sans Serif")))
{
  SETFONTSIZE(height, 12);
  HRESULT err = LoadTypeLib (OLESTR ("bole.tlb"), &pTL);
  if (!err) {
    ITypeInfo *pTI;
    err = pTL->GetTypeInfoOfGuid (IID_BOleFont, &pTI);
  }
  // EventHandler deal with ConnecctionPoints
  pEventList = new BEventList (1);
  if (pEventList) {
    pEventList->AddRef();
    pEventList->AddEventsSet (IID_IPropertyNotifySink, AsPIUnknown(this), 5);
  }
}
Esempio n. 28
0
ITypeLib *get_msxml3_typelib( LPWSTR *path )
{
    static WCHAR msxml3_path[MAX_PATH];

    EnterCriticalSection( &MSXML3_typelib_cs );

    if (!typelib)
    {
        TRACE("loading typelib\n");

        if (GetModuleFileNameW( hInstance, msxml3_path, MAX_PATH ))
            LoadTypeLib( msxml3_path, &typelib );
    }

    LeaveCriticalSection( &MSXML3_typelib_cs );

    if (path)
        *path = msxml3_path;

    if (typelib)
        ITypeLib_AddRef( typelib );

    return typelib;
}
Esempio n. 29
0
STDAPI DllUnregisterServer()
{
	HRESULT hr = AMovieDllRegisterServer2(FALSE);

	// unregister type library
	WCHAR achFileName[MAX_PATH];
	GetModuleFileNameW(g_hInst, achFileName, MAX_PATH);
	ITypeLib* pTypeLib;
	LoadTypeLib(achFileName, &pTypeLib);

	if (pTypeLib)
	{
		TLIBATTR* ptla;
		hr = pTypeLib->GetLibAttr(&ptla);
		if (SUCCEEDED(hr))
		{
			hr = UnRegisterTypeLib(ptla->guid, ptla->wMajorVerNum, ptla->wMinorVerNum, ptla->lcid, ptla->syskind);
			pTypeLib->ReleaseTLibAttr(ptla);
		}
		pTypeLib->Release();
	}

	return hr;
}
Esempio n. 30
0
/* Extract IIDs and CLSIDs from qedit type library */
static void
InitAllQeditTypeLibGUIDs()
{
    ITypeLib* pQeditTypeLib = 0;
    HRESULT result = LoadTypeLib(
        kFilenameQeditTypeLib.BeginReading(), &pQeditTypeLib
    );
    
    if (result == S_OK) {
        PRUint32 countTypeInfo = pQeditTypeLib->GetTypeInfoCount();
        ITypeInfo** typeInfoPtrArray = new ITypeInfo*[countTypeInfo];
        MEMBERID* memberIdArray = new MEMBERID[countTypeInfo];
        
        InitTypeLibGUID(
            pQeditTypeLib, typeInfoPtrArray, memberIdArray,
            kNameISampleGrabber, TKIND_INTERFACE, IID_ISampleGrabber
        );
        InitTypeLibGUID(
            pQeditTypeLib, typeInfoPtrArray, memberIdArray,
            kNameISampleGrabberCB, TKIND_INTERFACE, IID_ISampleGrabberCB
        );
        InitTypeLibGUID(
            pQeditTypeLib, typeInfoPtrArray, memberIdArray,
            kNameClassSampleGrabber, TKIND_COCLASS, CLSID_SampleGrabber
        );
        InitTypeLibGUID(
            pQeditTypeLib, typeInfoPtrArray, memberIdArray,
            kNameClassNullRenderer, TKIND_COCLASS, CLSID_NullRenderer
        );
        
        delete[] memberIdArray;
        delete[] typeInfoPtrArray;
    }
    
    SAFE_RELEASE(pQeditTypeLib);
}