| |
| INT GetBrowserVersion( |
| |
LPDWORD lpdwVersionMS, |
|
| |
LPDWORD lpdwVersionLS, |
|
| |
LPTSTR lpszVersion, |
|
| |
INT nMaxLength |
|
| ); |
The GetBrowserVersion method returns the browser runtime version information.
Parameters
- lpdwVersionMS
- A pointer to an unsigned integer which contains the major and
minor version numbers. This parameter may be NULL.
- lpdwVersionLS
- A pointer to an unsigned integer which contains the build and
release version numbers. This parameter may be NULL.
- lpszVersion
- A null-terminated string buffer which will contain the version
as a printable string. This parameter may be NULL, in which case the
version string is not copied but the method will still return the
length of the version string if successful. If this parameter is
NULL, the nMaxLength parameter should have a value of zero.
- nMaxLength
- An integer which specifies the maximum number of characters
which may be copied into the string buffer, including the
terminating null. If the lpszVersion parameter is NULL, this
parameter should be zero.
Return Value
If the method succeeds, the return value is the length of the
version string, not including the terminating null character. If
the method fails, the return value is zero. To get extended error
information, call GetLastError.
Remarks
The GetBrowserVersion method returns the version
information for the installed Microsoft Edge WebView2 Runtime. This is
the runtime that hosts the embedded browser control, and it is
separate from the version of the Edge browser that may be installed on
the system. The method can provide the version number as two 32-bit
values (major/minor and build/revision), and optionally as a formatted
string for display purposes. This method is useful for diagnostics,
logging, or when an application requires a specific minimum runtime
version to support certain features. If the WebView2 Runtime is not
installed or cannot be located, the method will fail and return
zero.
The version values returned by lpdwVersionMS and
lpdwVersionLS can be used with the HIWORD and
LOWORD macros to extract the individual components of
the version number (for example, major, minor, build, and revision).
The printable version string will match the same four-part format
commonly shown in Edge and WebView2 documentation (e.g.,
"126.0.2592.113").
The result is independent of whether a WebView window has already
been created or attached. It only reflects the version of the
installed runtime and does not indicate whether the runtime is
currently in use. For cases where you only need to check if a runtime
is available, use the RuntimeAvailable method instead.
Example
DWORD dwVerMS = 0, dwVerLS = 0;
TCHAR szVersion[64] = {0};
INT nLength = pWebView->GetBrowserVersion(&dwVerMS, &dwVerLS, szVersion, _countof(szVersion));
if (nLength > 0)
{
WORD wMajor = HIWORD(dwVerMS);
WORD wMinor = LOWORD(dwVerMS);
WORD wBuild = HIWORD(dwVerLS);
WORD wRevision = LOWORD(dwVerLS);
_tprintf(_T("WebView2 Runtime Version: %s\n"), szVersion);
_tprintf(_T("Major=%hu Minor=%hu Build=%hu Revision=%hu\n"), wMajor, wMinor, wBuild, wRevision);
}
else
{
_tprintf(_T("Unable to determine WebView2 Runtime version (Error 0x%lx)\n"), pWebView->GetLastError());
}
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
|
|