MsiDatabaseGetPrimaryKeysA function

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 MsiDatabaseGetPrimaryKeysA(
  MSIHANDLE hDatabase,
  LPCSTR    szTableName,
  MSIHANDLE *phRecord
);

Parameters

hDatabase

Handle to the database. See Obtaining a Database Handle.

szTableName

Specifies the name of the table from which to obtain primary key names.

phRecord

Pointer to the handle of the record that holds the primary key names.

Return Value

This function returns UINT.

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

   
Minimum supported client Windows Installer 5.0 on Windows Server 2012, Windows 8, 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 or Windows XP
Target Platform Windows
Header msiquery.h
Library Msi.lib
DLL Msi.dll

See Also

General Database Access Functions