Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Applies to:SQL Server
Devuelve información para la instancia de SQL Server Express LocalDB especificada, como si existe, la versión de LocalDB que usa, si se está ejecutando, etc.
La información se devuelve en un struct objeto denominado LocalDBInstanceInfo, que tiene la siguiente definición.
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
[Input] Nombre de la instancia.
pInstanceInfo
[Output] Búfer para almacenar información sobre la instancia de LocalDB.
dwInstanceInfoSize
[Input] Holds the size of the InstanceInfo buffer.
Returns
S_OK: la función se realizó correctamente.
| Error | Description |
|---|---|
| LOCALDB_ERROR_NOT_INSTALLED | SQL Server Express LocalDB no está instalado en el equipo. |
| LOCALDB_ERROR_INVALID_PARAMETER | Uno o más parámetros de entrada especificados no son válidos. |
| LOCALDB_ERROR_INVALID_INSTANCE_NAME | El nombre de instancia de especificado no es válido. |
| LOCALDB_ERROR_UNKNOWN_INSTANCE | La instancia no existe. |
| LOCALDB_ERROR_INSTANCE_FOLDER_PATH_TOO_LONG | La ruta de acceso donde se debe almacenar la instancia es mayor que MAX_PATH. |
| LOCALDB_ERROR_CANNOT_ACCESS_INSTANCE_FOLDER | No se puede tener acceso a una carpeta de instancia. |
| LOCALDB_ERROR_CANNOT_ACCESS_INSTANCE_REGISTRY | No se puede acceder a un registro de instancia. |
| LOCALDB_ERROR_INSTANCE_CONFIGURATION_CORRUPT | Una configuración de instancia está dañada. |
| LOCALDB_ERROR_INTERNAL_ERROR | Se ha producido un error inesperado. Vea el registro de eventos para obtener detalles. |
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. En caso contrario, devuelve LOCALDB_ERROR_INVALID_PARAMETER.
Un ejemplo típico de uso de LocalDBGetInstanceInfo API tiene este aspecto:
LocalDBInstanceInfo ii;
LocalDBInstanceInfo(L"Test", &ii, sizeof(LocalDBInstanceInfo));
Para obtener un ejemplo de código que usa la API de LocalDB, consulte Referencia de SQL Server Express LocalDB.