Applies to:SQL Server
지정된 SQL Server Express LocalDB 인스턴스에 대한 정보(예: 존재하는지 여부, 사용하는 LocalDB 버전, 실행 중인지 여부 등)를 반환합니다.
정보는 다음 정의가 있는 struct 명명 LocalDBInstanceInfo된 이름으로 반환됩니다.
typedef struct _LocalDBInstanceInfo
{
// Contains the size of the LocalDBInstanceInfo struct
DWORD cbLocalDBInstanceInfoSize;
// Holds the instance name
TLocalDBInstanceNamewszInstanceName;
// TRUE if the instance files exist on disk, FALSE otherwise
BOOL bExists;
// TRUE if the instance configuration registry is corrupted, FALSE otherwise
BOOLbConfigurationCorrupted;
// TRUE if the instance is running at the moment, FALSE otherwise
BOOL bIsRunning;
// Holds the LocalDB version for the instance in the format: major.minor.build.revision
DWORD dwMajor;
DWORD dwMinor;
DWORD dwBuild;
DWORD dwRevision;
// Holds the date and time when the instance was started for the last time
FILETIME ftLastStartUTC;
// Holds the name of the TDS named pipe to connect to the instance
WCHARwszConnection;
// TRUE if the instance is shared, FALSE otherwise
BOOLbIsShared;
// Holds the shared name for the instance (if the instance is shared)
TLocalDBInstanceNamewszSharedInstanceName;
// Holds the SID of the instance owner (if the instance is shared)
WCHARwszOwnerSID;
// TRUE if the instance is Automatic, FALSE otherwise
BOOLbIsAutomatic;
} LocalDBInstanceInfo;
Header file:msoledbsql.h
Syntax
HRESULT LocalDBGetInstanceInfo(
PCWSTR wszInstanceName ,
PLocalDBInstanceInfo pInstanceInfo ,
DWORD dwInstanceInfoSize
);
Arguments
wszInstanceName
[입력] 인스턴스 이름입니다.
pInstanceInfo
[출력] LocalDB 인스턴스에 대한 정보를 저장하는 버퍼입니다.
dwInstanceInfoSize
[Input] Holds the size of the InstanceInfo buffer.
Returns
S_OK: 함수가 성공했습니다.
| Error | Description |
|---|---|
| LOCALDB_ERROR_NOT_INSTALLED | SQL Server Express LocalDB는 컴퓨터에 설치되어 있지 않습니다. |
| LOCALDB_ERROR_INVALID_PARAMETER | 하나 이상의 지정된 입력 매개 변수가 잘못되었습니다. |
| LOCALDB_ERROR_INVALID_INSTANCE_NAME | 지정한 인스턴스 이름이 잘못되었습니다. |
| LOCALDB_ERROR_UNKNOWN_INSTANCE | 인스턴스가 없습니다. |
| LOCALDB_ERROR_INSTANCE_FOLDER_PATH_TOO_LONG | 인스턴스를 저장해야 하는 경로가 .보다 MAX_PATH깁니다. |
| LOCALDB_ERROR_CANNOT_ACCESS_INSTANCE_FOLDER | 인스턴스 폴더에 액세스할 수 없습니다. |
| LOCALDB_ERROR_CANNOT_ACCESS_INSTANCE_REGISTRY | 인스턴스 레지스트리에 액세스할 수 없습니다. |
| LOCALDB_ERROR_INSTANCE_CONFIGURATION_CORRUPT | 인스턴스 구성이 손상되었습니다. |
| LOCALDB_ERROR_INTERNAL_ERROR | 예기치 않은 오류가 발생했습니다. 자세한 내용은 이벤트 로그를 참조하세요. |
Details
The rationale behind the introduction of the struct size argument (lpInstanceInfoSize) is to enable the API to return different versions of the LocalDBInstanceInfostruct, effectively enabling forward and backward compatibility.
If the struct size argument (lpInstanceInfoSize) matches the size of a known version of the LocalDBInstanceInfostruct, that version of the struct is returned. 그렇지 않으면 LOCALDB_ERROR_INVALID_PARAMETER이 반환됩니다.
API 사용의 LocalDBGetInstanceInfo 일반적인 예는 다음과 같습니다.
LocalDBInstanceInfo ii;
LocalDBInstanceInfo(L"Test", &ii, sizeof(LocalDBInstanceInfo));
LocalDB API를 사용하는 코드 샘플은 SQL Server Express LocalDB 참조를 참조하세요.