Guillaume Charifi guillaume.charifi@sfr.fr writes:
- strcpyW(szTLBPath, szPath);
- snprintfW(szStringName, sizeof(szStringName)/sizeof(WCHAR), resFormatStrW, PtrToInt(lpszIntName));
- strcatW(szTLBPath, szStringName);
- ret = TLB_PEFile_Open(szPath, PtrToInt(lpszIntName), &pBase, &dwTLBLength, &pFile);
- if (ret == TYPE_E_CANTLOADLIBRARY)
ret = TLB_NEFile_Open(szPath, PtrToInt(lpszIntName), &pBase, &dwTLBLength, &pFile);- if (ret == TYPE_E_CANTLOADLIBRARY)
ret = TLB_Mapping_Open(szPath, &pBase, &dwTLBLength, &pFile);- if (SUCCEEDED(ret))
- {
if (dwTLBLength >= 4){DWORD dwSignature = FromLEDWord(*((DWORD*) pBase));if (dwSignature == MSFT_SIGNATURE)pTLib = ITypeLib2_Constructor_MSFT(pBase, dwTLBLength);else if (dwSignature == SLTG_SIGNATURE)pTLib = ITypeLib2_Constructor_SLTG(pBase, dwTLBLength);else{FIXME("Header type magic 0x%08x not supported.\n", dwSignature);ret = E_FAIL;}}elseret = E_FAIL;IUnknown_Release(pFile);- }
You should avoid duplicating all that code.
- if(pTLib) {
ITypeLibImpl *impl = impl_from_ITypeLib2(pTLib);ret = UuidEqual((UUID *)This->guid, (UUID *)TLB_get_guid_null(impl->guid), &rpc_stat);ITypeLib_Release((ITypeLib *)pTLib);ret = (ret == TRUE) ? LoadTypeLibEx(szTLBPath, REGKIND_NONE, (ITypeLib **)&pTLib) : E_FAIL;- }
That's pretty ugly.