Applies to:SQL Server
返回有关指定的 SQL Server Express LocalDB 版本的信息,如该版本是否存在以及完整的 LocalDB 版本号(包括内部版本号和发行版本号)。
该信息以命名LocalDBVersionInfo形式struct返回,其定义如下。
typedef struct _LocalDBVersionInfo
{
// Contains the size of the LocalDBVersionInfo struct
DWORD cbLocalDBVersionInfoSize;
// Holds the version name
TLocalDBVersionwszVersion;
// TRUE if the instance files exist on disk, FALSE otherwise
BOOL bExists;
// Holds the LocalDB version for the instance in the format: major.minor.build.revision
DWORD dwMajor;
DWORD dwMinor;
DWORD dwBuild;
DWORD dwRevision;
} LocalDBVersionInfo;
Header file:msoledbsql.h
Syntax
HRESULT LocalDBGetVersionInfo(
PCWSTR wszVersionName ,
PLocalDBVersionInfo pVersionInfo ,
DWORD dwVersionInfoSize);
Arguments
wszVersionName
[输入] LocalDB 版本名称。
pVersionInfo
[输出] 要存储有关 LocalDB 版本信息的缓冲区。
dwVersionInfoSize
[Input] Holds the size of the VersionInfo buffer.
Returns
S_OK:函数成功。
| Error | Description |
|---|---|
| LOCALDB_ERROR_NOT_INSTALLED | 计算机上未安装 SQL Server Express LocalDB。 |
| LOCALDB_ERROR_INVALID_PARAMETER | 一个或多个指定的输入参数无效。 |
| LOCALDB_ERROR_UNKNOWN_VERSION | 指定的 LocalDB 版本不存在。 |
| LOCALDB_ERROR_INTERNAL_ERROR | 发生了意外错误。 有关详细信息,请参阅事件日志。 |
Details
The rationale behind the introduction of the struct size argument (lpVersionInfoSize) is to enable the API to return different versions of the LocalDBVersionInfostruct, effectively enabling forward and backward compatibility.
If the struct size argument (lpVersionInfoSize) matches the size of a known version of the LocalDBVersionInfostruct, that version of the struct is returned. 否则将返回 LOCALDB_ERROR_INVALID_PARAMETER。
API 用法的典型示例 LocalDBGetVersionInfo 如下所示:
LocalDBVersionInfo vi;
LocalDBVersionInfo(L"11.0", &vi, sizeof(LocalDBVersionInfo));
Remarks
有关使用 LocalDB API 的代码示例,请参阅 SQL Server Express LocalDB 参考。