Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Installer
Installer Functions
 MsiCloseHandle Function

  Switch on low bandwidth view
MsiCloseHandle Function

The MsiCloseHandle function closes an open installation handle.

Syntax

C++
UINT MsiCloseHandle(
  __in  MSIHANDLE hAny
);

Parameters

hAny [in]

Specifies any open installation handle.

Return Value

ValueMeaning
ERROR_INVALID_HANDLE

An invalid handle was passed to the function.

ERROR_SUCCESS

The function succeeded.

 

Remarks

MsiCloseHandle must be called from the same thread that requested the creation of the handle.

The following functions supply handles that should be closed after use by calling MsiCloseHandle:

MsiCreateRecord
MsiGetActiveDatabase
MsiGetLastErrorRecord
MsiOpenPackage
MsiOpenProduct
MsiOpenDatabase
MsiDatabaseOpenView
MsiViewFetch
MsiViewGetColumnInfo
MsiDatabaseGetPrimaryKeys
MsiGetSummaryInformation
MsiEnableUIPreview

Note that when writing custom actions, 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 example, if you use code like this:

MSIHANDLE hRec = MsiCreateRecord(3);

Change it to:

PMSIHANDLE hRec = MsiCreateRecord(3);

Requirements

VersionWindows 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. See the Windows Installer Run-Time Requirements for information about the minimum Microsoft Windows service pack that is required by a Windows Installer version.
HeaderMsi.h
LibraryMsi.lib
DLLMsi.dll

See Also

Handle Management Functions

Send comments about this topic to Microsoft

Build date: 6/25/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Hex Values for Win32 error codes Published as part of Open Protocol Specifications      Robert Flaming - MSFT   |   Edit   |   Show History

As a part of the Open Protocol Specifications, the hex values for Win32 error codes can now be found at http://msdn2.microsoft.com/en-us/library/cc231199.aspx.

vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("msi.dll", CharSet:=CharSet.Unicode)> _
Public Shared Function MsiCloseHandle(ByVal hAny As Integer) As UInt32
End Function
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("msi.dll", CharSet=CharSet.Unicode)]
internal static extern uint MsiCloseHandle(int hAny);
Tags What's this?: c# (x) syntax (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker