Condividi tramite


Funzione LocalDBGetInstanceInfo

Vengono restituite le informazioni per l'istanza del database locale di SQL Server Express specificata, se esistente, la versione del database locale utilizzata dall'istanza, se quest'ultima è in esecuzione e così via.

Le informazioni vengono restituite in uno struct denominato LocalDBInstanceInfo, che dispone della definizione seguente.

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;

File di intestazione: sqlncli.h

Sintassi

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

Parametri

  • wszInstanceName
    [Input] Nome dell'istanza.

  • pInstanceInfo
    [Output] Buffer per archiviare le informazioni sull'istanza del database locale.

  • dwInstanceInfoSize
    [Input] Vengono mantenute le dimensioni del buffer InstanceInfo.

Valori restituiti

Dettagli

La logica alla base dell'introduzione dell'argomento delle dimensioni struct (lpInstanceInfoSize) è consentire la restituzione di versioni differenti dello struct LocalDBInstanceInfo da parte dell'API, abilitando in modo efficiente la compatibilità con le versioni precedenti e successive.

Se l'argomento delle dimensioni struct (lpInstanceInfoSize) corrisponde alle dimensioni di una versione nota dello struct LocalDBInstanceInfo, viene restituita tale versione dello struct. In caso contrario, viene restituito LOCALDB_ERROR_INVALID_PARAMETER.

L'aspetto di un esempio tipico di utilizzo dell'API LocalDBGetInstanceInfo è simile al seguente:

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

Per un esempio di codice in cui viene utilizzata l'API LocalDB, vedere Riferimento al database locale di SQL Server Express.

Vedere anche

Concetti

Informazioni sulla versione e intestazione del database locale di SQL Server Express