Freigeben über


LocalDBGetInstanceInfo-Funktion

Gibt Informationen für die angegebene SQL Server Express LocalDB-Instanz zurück (beispielsweise, ob sie vorhanden ist, die verwendete LocalDB-Version, ob sie ausgeführt wird usw.).

Die Informationen werden in einem struct mit der Bezeichnung LocalDBInstanceInfo und folgender Definition zurückgegeben.

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;

Headerdatei: sqlncli.h

Syntax

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

Parameter

  • wszInstanceName
    [Eingabe] Der Name der Instanz.

  • pInstanceInfo
    [Ausgabe] Der Puffer zum Speichern der Informationen zur LocalDB-Instanz.

  • dwInstanceInfoSize
    [Eingabe] Enthält die Größe des InstanceInfo-Puffers.

Rückgabewerte

Details

Der Grund für die Einführung in des struct-Größenarguments (lpInstanceInfoSize) ist der API zu ermöglichen, verschiedene Versionen von LocalDBInstanceInfo struct zurückzugeben und Aufwärts- und Abwärtskompatibilität effektiv zu unterstützen.

Falls das struct-Größenargument (lpInstanceInfoSize) mit der Größe einer bekannten Version von LocalDBInstanceInfo struct übereinstimmt, wird diese Version von struct zurückgegeben. Andernfalls wird LOCALDB_ERROR_INVALID_PARAMETER zurückgegeben.

Beispiele für die Verwendung der LocalDBGetInstanceInfo-API sehen meist wie folgt aus:

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

Ein Codebeispiel, in dem die LocalDB-API verwendet wird, finden Sie unter SQL Server Express LocalDB-Verweis.

Siehe auch

Konzepte

SQL Server Express LocalDB-Header und Versionsinformationen