Je viens d'intégrer un contrôle ActiveX IE/navigateur Web dans mon application C++ (MFC). Et je suis curieux comment puis-je obtenir la version de IE utilisée pour cela?Comment obtenir une version du contrôle IE ActiveX incorporé?
1
A
Répondre
0
Il s'agit en quelque sorte d'un hack, mais vous pouvez utiliser mshtml.dll
qui est un integral part de n'importe quel contrôle IE et récupérer sa version. Vient ensuite l'extrait de code d'un de mes projets:
#define SIZEOF(f) (sizeof(f)/sizeof(f[0]))
HMODULE hModMshtl = ::GetModuleHandle(L"mshtml.dll");
if(hModMshtl)
{
TCHAR buffMshtl[MAX_PATH];
buffMshtl[0] = 0;
::GetModuleFileName(hModMshtl, buffMshtl, SIZEOF(buffMshtl));
buffMshtl[SIZEOF(buffMshtl) - 1] = 0;
CString strProdName;
VS_FIXEDFILEINFO vi;
if(GetFileVersionAndProductName(buffMshtl, &vi, &strProdName))
{
//Got it
_tprintf(L"%s v.%d.%d.%d.%d",
strProdName.GetString(),
(DWORD)((vi.dwProductVersionLS & 0xFFFF0000) >> 16),
(DWORD)(vi.dwProductVersionLS & 0xFFFF),
(DWORD)((vi.dwProductVersionMS & 0xFFFF0000) >> 16),
(DWORD)(vi.dwProductVersionMS & 0xFFFF)
);
}
}
et voici comment vous pouvez obtenir sa version:
BOOL GetFileVersionAndProductName(LPCTSTR pFilePath, VS_FIXEDFILEINFO* pOutVersionInfo, CString* pOutProductName)
{
BOOL bRes = FALSE;
CString strFilePath = pFilePath;
LPCTSTR pDescBuf = NULL;
struct LANGANDCODEPAGE {
WORD wLanguage;
WORD wCodePage;
};
CString strProdName;
BYTE* pData = NULL;
if(!strFilePath.IsEmpty())
{
//Get size needed
DWORD dwDummy;
DWORD dwSz = ::GetFileVersionInfoSize((LPTSTR)strFilePath.GetString(), &dwDummy);
if(dwSz > 0)
{
//Reserve mem
pData = new (std::nothrow)BYTE[dwSz];
if(pData)
{
//Retrieve version info
if(::GetFileVersionInfo((LPTSTR)strFilePath.GetString(), NULL, dwSz, pData))
{
UINT nczBufLn;
VS_FIXEDFILEINFO* pVi = NULL;
if(VerQueryValue(pData, _T("\\"), (VOID**)&pVi, &nczBufLn))
{
if(pVi &&
nczBufLn >= sizeof(*pVi) &&
pVi->dwSignature == 0xFEEF04BD)
{
//Got it
bRes = TRUE;
if(pOutVersionInfo)
*pOutVersionInfo = *pVi;
}
}
struct LANGANDCODEPAGE
{
WORD wLanguage;
WORD wCodePage;
} *lpTranslate = NULL;
// Read the list of languages and code pages.
UINT cbTranslate;
if(VerQueryValue(pData, L"\\VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &cbTranslate))
{
//Get first language
if(lpTranslate &&
cbTranslate >= sizeof(*lpTranslate))
{
//Retrieve product name
CString strBlock;
strBlock.Format(L"\\StringFileInfo\\%04x%04x\\ProductName",
lpTranslate[0].wLanguage,
lpTranslate[0].wCodePage);
UINT dwProdLn = 0;
VOID* lpBufferName = NULL;
if(VerQueryValue(pData, strBlock, &lpBufferName, &dwProdLn))
{
//Get name
memcpy(strProdName.GetBufferSetLength(dwProdLn), lpBufferName, dwProdLn * sizeof(TCHAR));
strProdName.ReleaseBuffer();
}
}
}
}
}
}
}
if(pOutProductName)
*pOutProductName = strProdName;
//Free mem
if(pData)
delete[] pData;
return bRes;
}
Questions connexes
- 1. Installation du contrôle ActiveX dans IE 64 bits
- 2. Détection du conteneur IE à partir du contrôle ActiveX
- 3. Activex Update - IE
- 4. IE est le contrôle ActiveX installé?
- 5. Contrôle de version ActiveX VB 6.0
- 6. Déployer une nouvelle version d'un contrôle ActiveX existant
- 7. Programmation du contrôle Visio ActiveX
- 8. Développement du contrôle ActiveX pour Windows CE
- 9. Détermination du contrôle ActiveX "actif"
- 10. Héritage du contrôle ActiveX existant
- 11. ie ActiveX vs addon
- 12. Comment autoriser l'invite d'installation ActiveX à s'afficher si elle est installée ActiveX a une ancienne version
- 13. Vb6: nom du contrôle ActiveX
- 14. Comment obtenir des informations de VS_VERSION_INFO dans le contrôle ActiveX
- 15. Le contrôle ActiveX ne s'affiche pas correctement dans ie
- 16. Utilisation du contrôle ActiveX avec les paramètres
- 17. ActiveX n'apparaît pas sur IE
- 18. Suppression de la bordure sur activex ie contrôle
- 19. Contrôle ActiveX pour le téléchargement par glisser-déposer dans IE
- 20. Comment créer plusieurs versions d'un contrôle ActiveX?
- 21. Comment enregistrer un contrôle ActiveX?
- 22. Utilisation d'un contrôle ActiveX provenant d'un autre contrôle ActiveX sur une page Web
- 23. ActiveX ne fonctionne pas dans IE 11
- 24. Contrôle ActiveX dans l'applet Java
- 25. Comment créer un contrôle ActiveX déployable?
- 26. Comment accéder aux méthodes d'un contrôle ActiveX incorporé à l'aide de jQuery?
- 27. Impression PowerPoint à l'aide du contrôle ActiveX
- 28. ActiveX dans IE - le désactiver en dehors du navigateur?
- 29. Le constructeur du contrôle ActiveX invoque une deuxième fois
- 30. comment saisir correctement une URL de IE avec ActiveX?
démarrage IE à partir du bureau et utiliser l'aide + A propos. –
@HansPassant: Très drôle. – c00000fd
[Cette réponse] (http://stackoverflow.com/a/2897215/2065121) à une question connexe peut être utile. –