--- title: "LocalDBGetInstances Function | Microsoft Docs" ms.custom: "" ms.date: "03/06/2017" ms.prod: sql ms.prod_service: "database-engine" ms.reviewer: "" ms.technology: ms.topic: "reference" apiname: - "LocalDBGetInstances" apilocation: - "sqluserinstance.dll" apitype: "DLLExport" ms.assetid: f95a9980-8bc0-426c-8aa1-e2660b6784cf author: "CarlRabeler" ms.author: "carlrab" --- # LocalDBGetInstances Function [!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md](../../includes/appliesto-ss-xxxx-xxxx-xxx-md.md)] Returns all SQL Server Express LocalDB instances with the given version. **Header file:** sqlncli.h ## Syntax ``` #define MAX_LOCALDB_INSTANCE_NAME_LENGTH 128typedef WCHAR TLocalDBInstanceName[MAX_LOCALDB_INSTANCE_NAME_LENGTH + 1];typedef TLocalDBInstanceName* PTLocalDBInstanceName; HRESULT LocalDBGetInstances( PTLocalDBInstanceName pInstanceNames, LPDWORD lpdwNumberOfInstances ); ``` ## Parameters *pInstanceNames* [Output] When this function returns, contains the names of both named and default LocalDB instances on the user's workstation. *lpdwNumberOfInstances* [Input/Output] On input, contains the number of slots for instance names in the *pInstanceNames* buffer. On output, contains the number of LocalDB instances found on the user's workstation. ## Returns S_OK The function succeeded. [LOCALDB_ERROR_NOT_INSTALLED](../../relational-databases/express-localdb-error-messages/localdb-error-not-installed.md) SQL Server Express LocalDB is not installed on the computer. [LOCALDB_ERROR_INVALID_PARAMETER](../../relational-databases/express-localdb-error-messages/localdb-error-invalid-parameter.md) One or more specified input parameters are invalid. [LOCALDB_ERROR_INSUFFICIENT_BUFFER](../../relational-databases/express-localdb-error-messages/localdb-error-insufficient-buffer.md) The input buffer is too short, and truncation was not requested. [LOCALDB_ERROR_INSTANCE_FOLDER_PATH_TOO_LONG](../../relational-databases/express-localdb-error-messages/localdb-error-instance-folder-path-too-long.md) The path where the instance should be stored is longer than MAX_PATH. [LOCALDB_ERROR_CANNOT_ACCESS_INSTANCE_REGISTRY](../../relational-databases/express-localdb-error-messages/localdb-error-cannot-access-instance-registry.md) An instance registry cannot be accessed. [LOCALDB_ERROR_INSTANCE_CONFIGURATION_CORRUPT](../../relational-databases/express-localdb-error-messages/localdb-error-instance-configuration-corrupt.md) An instance configuration is corrupted. [LOCALDB_ERROR_INTERNAL_ERROR](../../relational-databases/express-localdb-error-messages/localdb-error-internal-error.md) An unexpected error occurred. See the event log for details. ## Remarks For a code sample that uses LocalDB API, see [SQL Server Express LocalDB Reference](../../relational-databases/sql-server-express-localdb-reference.md). ## See Also [SQL Server Express LocalDB Header and Version Information](../../relational-databases/express-localdb-instance-apis/sql-server-express-localdb-header-and-version-information.md)