The
MsiDatabaseGetPrimaryKeys function returns a record containing the names of all the primary key columns for a specified table. This function returns a handle that should be closed using
MsiCloseHandle.
Syntax
UINT MsiDatabaseGetPrimaryKeys(
__in MSIHANDLE hDatabase,
__in LPCTSTR szTableName,
__out MSIHANDLE *phRecord
);
Parameters
- hDatabase [in]
-
Handle to the database. See
Obtaining a Database Handle.
- szTableName [in]
-
Specifies the name of the table from which to obtain primary key names.
- phRecord [out]
-
Pointer to the handle of the record that holds the primary key names.
Return Value
- ERROR_INVALID_HANDLE
-
An invalid or inactive handle was supplied.
- ERROR_INVALID_PARAMETER
-
An invalid parameter was passed to the function.
- ERROR_INVALID_TABLE
-
An invalid table was passed to the function.
- ERROR_SUCCESS
-
The function succeeded.
Remarks
The field count of the returned record is the count of primary key columns returned by the
MsiDatabaseGetPrimaryKeys function. The returned record contains the table name in Field (0) and the column names that make up the primary key names in succeeding fields. These primary key names correspond to the column numbers for the fields.
This function cannot be used with the
_Tables table or the
_Columns table.
Note that it is recommended to use variables of type PMSIHANDLE because the installer closes PMSIHANDLE objects as they go out of scope, whereas you must close MSIHANDLE objects by calling
MsiCloseHandle. For more information see Use PMSIHANDLE instead of HANDLE section in the Windows Installer Best Practices.
Requirements
| Version | Windows Installer 5.0 on Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003, Windows XP, and Windows 2000 |
| Header | Msiquery.h |
| Library | Msi.lib |
| DLL | Msi.dll |
| Unicode and ANSI names | MsiDatabaseGetPrimaryKeysW (Unicode) and MsiDatabaseGetPrimaryKeysA (ANSI) |
See Also
- General Database Access Functions
Send comments about this topic to Microsoft
Build date: 11/12/2009