Partager via


Fonction LocalDBGetInstanceInfo

Retourne des informations pour l'instance de base de données locale SQL Server Express (LocalDB) spécifiée, entre autres si elle existe, la version de LocalDB qu'elle utilise, si elle s'exécute, et ainsi de suite.

Les informations sont retournées dans un struct nommé LocalDBInstanceInfo, qui a la définition suivante.

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;

Fichier d'en-tête : sqlncli.h

Syntaxe

HRESULT LocalDBGetInstanceInfo(
           PCWSTR wszInstanceName,
           PLocalDBInstanceInfo pInstanceInfo,
           DWORD dwInstanceInfoSize 
);

Paramètres

  • wszInstanceName
    [Entrée] Nom de l'instance.

  • pInstanceInfo
    [Sortie] La mémoire tampon pour stocker des informations sur l'instance de LocalDB.

  • dwInstanceInfoSize
    [Entrée] contient la taille de la mémoire tampon d'InstanceInfo.

Valeurs retournées

Détails

L'introduction de l'argument de taille de struct (lpInstanceInfoSize) s'explique par le fait que l'API doit retourner des versions de LocalDBInstanceInfo struct, permettant efficacement la compatibilité ascendante et la compatibilité descendante.

Si l'argument de taille de struct (lpInstanceInfoSize) correspond à la taille d'une version connue de LocalDBInstanceInfo struct, cette version de struct est retournée. Sinon, LOCALDB_ERROR_INVALID_PARAMETER est retourné.

Un exemple classique d'utilisation de l'API LocalDBGetInstanceInfo ressemble à ceci :

LocalDBInstanceInfo ii;
LocalDBInstanceInfo(L”Test”, &ii, sizeof(LocalDBInstanceInfo));

Pour un exemple de code qui utilise l'API LocalDB, consultez Référence SQL Server Express LocalDB.

Voir aussi

Concepts

En-tête et informations de version SQL Server Express LocalDB