📄 msi.h
字号:
/*****************************************************************************\
* *
* msi.h - - Interface for external access to Installer Service *
* *
* Version 1.0 *
* *
* NOTES: All buffers sizes are TCHAR count, null included only on input *
* Return argument pointers may be null if not interested in value *
* *
* Copyright (c) 1999, Microsoft Corp. All rights reserved. *
* *
\*****************************************************************************/
#ifndef _MSI_H_
#pragma option push -b -a8 -pc -A- /*P_O_Push*/
#define _MSI_H_
#ifndef _WIN32_MSI
#if (_WIN32_WINNT >= 0x0500)
#define _WIN32_MSI 110
#else
#define _WIN32_MSI 100
#endif //(_WIN32_WINNT >= 0x0500)
#endif // !_WIN32_MSI
// --------------------------------------------------------------------------
// Installer generic handle definitions
// --------------------------------------------------------------------------
typedef unsigned long MSIHANDLE; // abstract generic handle, 0 == no handle
#ifdef __cplusplus
extern "C" {
#endif
// Close a open handle of any type
// All handles obtained from API calls must be closed when no longer needed
// Normally succeeds, returning TRUE.
UINT WINAPI MsiCloseHandle(MSIHANDLE hAny);
// Close all handles open in the process, a diagnostic call
// This should NOT be used as a cleanup mechanism -- use PMSIHANDLE class
// Can be called at termination to assure that all handles have been closed
// Returns 0 if all handles have been close, else number of open handles
UINT WINAPI MsiCloseAllHandles();
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
// C++ wrapper object to automatically free handle when going out of scope
class PMSIHANDLE
{
MSIHANDLE m_h;
public:
PMSIHANDLE():m_h(0){}
PMSIHANDLE(MSIHANDLE h):m_h(h){}
~PMSIHANDLE(){if (m_h!=0) MsiCloseHandle(m_h);}
void operator =(MSIHANDLE h) {if (m_h) MsiCloseHandle(m_h); m_h=h;}
operator MSIHANDLE() {return m_h;}
MSIHANDLE* operator &() {if (m_h) MsiCloseHandle(m_h); m_h = 0; return &m_h;}
};
#endif //__cplusplus
// Install message type for callback is a combination of the following:
// A message box style: MB_*, where MB_OK is the default
// A message box icon type: MB_ICON*, where no icon is the default
// A default button: MB_DEFBUTTON?, where MB_DEFBUTTON1 is the default
// One of the following install message types, no default
typedef enum tagINSTALLMESSAGE
{
INSTALLMESSAGE_FATALEXIT = 0x00000000L, // premature termination, possibly fatal OOM
INSTALLMESSAGE_ERROR = 0x01000000L, // formatted error message
INSTALLMESSAGE_WARNING = 0x02000000L, // formatted warning message
INSTALLMESSAGE_USER = 0x03000000L, // user request message
INSTALLMESSAGE_INFO = 0x04000000L, // informative message for log
INSTALLMESSAGE_FILESINUSE = 0x05000000L, // list of files in use that need to be replaced
INSTALLMESSAGE_RESOLVESOURCE = 0x06000000L, // request to determine a valid source location
INSTALLMESSAGE_OUTOFDISKSPACE = 0x07000000L, // insufficient disk space message
INSTALLMESSAGE_ACTIONSTART = 0x08000000L, // start of action: action name & description
INSTALLMESSAGE_ACTIONDATA = 0x09000000L, // formatted data associated with individual action item
INSTALLMESSAGE_PROGRESS = 0x0A000000L, // progress gauge info: units so far, total
INSTALLMESSAGE_COMMONDATA = 0x0B000000L, // product info for dialog: language Id, dialog caption
INSTALLMESSAGE_INITIALIZE = 0x0C000000L, // sent prior to UI initialization, no string data
INSTALLMESSAGE_TERMINATE = 0x0D000000L, // sent after UI termination, no string data
INSTALLMESSAGE_SHOWDIALOG = 0x0E000000L, // sent prior to display or authored dialog or wizard
} INSTALLMESSAGE;
// external error handler supplied to installation API functions
typedef int (WINAPI *INSTALLUI_HANDLERA)(LPVOID pvContext, UINT iMessageType, LPCSTR szMessage);
// external error handler supplied to installation API functions
typedef int (WINAPI *INSTALLUI_HANDLERW)(LPVOID pvContext, UINT iMessageType, LPCWSTR szMessage);
#ifdef UNICODE
#define INSTALLUI_HANDLER INSTALLUI_HANDLERW
#else
#define INSTALLUI_HANDLER INSTALLUI_HANDLERA
#endif // !UNICODE
typedef enum tagINSTALLUILEVEL
{
INSTALLUILEVEL_NOCHANGE = 0, // UI level is unchanged
INSTALLUILEVEL_DEFAULT = 1, // default UI is used
INSTALLUILEVEL_NONE = 2, // completely silent installation
INSTALLUILEVEL_BASIC = 3, // simple progress and error handling
INSTALLUILEVEL_REDUCED = 4, // authored UI, wizard dialogs suppressed
INSTALLUILEVEL_FULL = 5, // authored UI with wizards, progress, errors
INSTALLUILEVEL_ENDDIALOG = 0x80, // display success/failure dialog at end of install
INSTALLUILEVEL_PROGRESSONLY = 0x40, // display only progress dialog
} INSTALLUILEVEL;
typedef enum tagINSTALLSTATE
{
INSTALLSTATE_NOTUSED = -7, // component disabled
INSTALLSTATE_BADCONFIG = -6, // configuration data corrupt
INSTALLSTATE_INCOMPLETE = -5, // installation suspended or in progress
INSTALLSTATE_SOURCEABSENT = -4, // run from source, source is unavailable
INSTALLSTATE_MOREDATA = -3, // return buffer overflow
INSTALLSTATE_INVALIDARG = -2, // invalid function argument
INSTALLSTATE_UNKNOWN = -1, // unrecognized product or feature
INSTALLSTATE_BROKEN = 0, // broken
INSTALLSTATE_ADVERTISED = 1, // advertised feature
INSTALLSTATE_REMOVED = 1, // component being removed (action state, not settable)
INSTALLSTATE_ABSENT = 2, // uninstalled (or action state absent but clients remain)
INSTALLSTATE_LOCAL = 3, // installed on local drive
INSTALLSTATE_SOURCE = 4, // run from source, CD or net
INSTALLSTATE_DEFAULT = 5, // use default, local or source
} INSTALLSTATE;
typedef enum tagUSERINFOSTATE
{
USERINFOSTATE_MOREDATA = -3, // return buffer overflow
USERINFOSTATE_INVALIDARG = -2, // invalid function argument
USERINFOSTATE_UNKNOWN = -1, // unrecognized product
USERINFOSTATE_ABSENT = 0, // user info and PID not initialized
USERINFOSTATE_PRESENT = 1, // user info and PID initialized
} USERINFOSTATE;
typedef enum tagINSTALLLEVEL
{
INSTALLLEVEL_DEFAULT = 0, // install authored default
INSTALLLEVEL_MINIMUM = 1, // install only required features
INSTALLLEVEL_MAXIMUM = 0xFFFF, // install all features
} INSTALLLEVEL; // intermediate levels dependent on authoring
typedef enum tagREINSTALLMODE // bit flags
{
REINSTALLMODE_REPAIR = 0x00000001, // Reserved bit - currently ignored
REINSTALLMODE_FILEMISSING = 0x00000002, // Reinstall only if file is missing
REINSTALLMODE_FILEOLDERVERSION = 0x00000004, // Reinstall if file is missing, or older version
REINSTALLMODE_FILEEQUALVERSION = 0x00000008, // Reinstall if file is missing, or equal or older version
REINSTALLMODE_FILEEXACT = 0x00000010, // Reinstall if file is missing, or not exact version
REINSTALLMODE_FILEVERIFY = 0x00000020, // checksum executables, reinstall if missing or corrupt
REINSTALLMODE_FILEREPLACE = 0x00000040, // Reinstall all files, regardless of version
REINSTALLMODE_MACHINEDATA = 0x00000080, // insure required machine reg entries
REINSTALLMODE_USERDATA = 0x00000100, // insure required user reg entries
REINSTALLMODE_SHORTCUT = 0x00000200, // validate shortcuts items
REINSTALLMODE_PACKAGE = 0x00000400, // use re-cache source install package
} REINSTALLMODE;
typedef enum tagINSTALLOGMODE // bit flags for use with MsiEnableLog and MsiSetExternalUI
{
INSTALLLOGMODE_FATALEXIT = (1 << (INSTALLMESSAGE_FATALEXIT >> 24)),
INSTALLLOGMODE_ERROR = (1 << (INSTALLMESSAGE_ERROR >> 24)),
INSTALLLOGMODE_WARNING = (1 << (INSTALLMESSAGE_WARNING >> 24)),
INSTALLLOGMODE_USER = (1 << (INSTALLMESSAGE_USER >> 24)),
INSTALLLOGMODE_INFO = (1 << (INSTALLMESSAGE_INFO >> 24)),
INSTALLLOGMODE_RESOLVESOURCE = (1 << (INSTALLMESSAGE_RESOLVESOURCE >> 24)),
INSTALLLOGMODE_OUTOFDISKSPACE = (1 << (INSTALLMESSAGE_OUTOFDISKSPACE >> 24)),
INSTALLLOGMODE_ACTIONSTART = (1 << (INSTALLMESSAGE_ACTIONSTART >> 24)),
INSTALLLOGMODE_ACTIONDATA = (1 << (INSTALLMESSAGE_ACTIONDATA >> 24)),
INSTALLLOGMODE_COMMONDATA = (1 << (INSTALLMESSAGE_COMMONDATA >> 24)),
INSTALLLOGMODE_PROPERTYDUMP = (1 << (INSTALLMESSAGE_PROGRESS >> 24)), // log only
INSTALLLOGMODE_VERBOSE = (1 << (INSTALLMESSAGE_INITIALIZE >> 24)), // log only
INSTALLLOGMODE_PROGRESS = (1 << (INSTALLMESSAGE_PROGRESS >> 24)), // external handler only
INSTALLLOGMODE_INITIALIZE = (1 << (INSTALLMESSAGE_INITIALIZE >> 24)), // external handler only
INSTALLLOGMODE_TERMINATE = (1 << (INSTALLMESSAGE_TERMINATE >> 24)), // external handler only
INSTALLLOGMODE_SHOWDIALOG = (1 << (INSTALLMESSAGE_SHOWDIALOG >> 24)), // external handler only
} INSTALLLOGMODE;
typedef enum tagINSTALLLOGATTRIBUTES // flag attributes for MsiEnableLog
{
INSTALLLOGATTRIBUTES_APPEND = (1 << 0),
INSTALLLOGATTRIBUTES_FLUSHEACHLINE = (1 << 1),
} INSTALLLOGATTRIBUTES;
typedef enum tagINSTALLFEATUREATTRIBUTE // bit flags
{
INSTALLFEATUREATTRIBUTE_FAVORLOCAL = 1 << 0,
INSTALLFEATUREATTRIBUTE_FAVORSOURCE = 1 << 1,
INSTALLFEATUREATTRIBUTE_FOLLOWPARENT = 1 << 2,
INSTALLFEATUREATTRIBUTE_FAVORADVERTISE = 1 << 3,
INSTALLFEATUREATTRIBUTE_DISALLOWADVERTISE = 1 << 4,
INSTALLFEATUREATTRIBUTE_NOUNSUPPORTEDADVERTISE = 1 << 5,
} INSTALLFEATUREATTRIBUTE;
typedef enum tagINSTALLMODE
{
INSTALLMODE_NOSOURCERESOLUTION = -3, // skip source resolution
INSTALLMODE_NODETECTION = -2, // skip detection
INSTALLMODE_EXISTING = -1, // provide, if available
INSTALLMODE_DEFAULT = 0, // install, if absent
} INSTALLMODE;
#define MAX_FEATURE_CHARS 38 // maximum chars in feature name (same as string GUID)
// Product info attributes: advertised information
#define INSTALLPROPERTY_TRANSFORMS __TEXT("Transforms")
#define INSTALLPROPERTY_LANGUAGE __TEXT("Language")
#define INSTALLPROPERTY_PRODUCTNAME __TEXT("ProductName")
#define INSTALLPROPERTY_ASSIGNMENTTYPE __TEXT("AssignmentType")
#define INSTALLPROPERTY_PACKAGECODE __TEXT("PackageCode")
#define INSTALLPROPERTY_VERSION __TEXT("Version")
#if (_WIN32_MSI >= 110)
#define INSTALLPROPERTY_PRODUCTICON __TEXT("ProductIcon")
#endif //(_WIN32_MSI >= 110)
// Product info attributes: installed information
#define INSTALLPROPERTY_INSTALLEDPRODUCTNAME __TEXT("InstalledProductName")
#define INSTALLPROPERTY_VERSIONSTRING __TEXT("VersionString")
#define INSTALLPROPERTY_HELPLINK __TEXT("HelpLink")
#define INSTALLPROPERTY_HELPTELEPHONE __TEXT("HelpTelephone")
#define INSTALLPROPERTY_INSTALLLOCATION __TEXT("InstallLocation")
#define INSTALLPROPERTY_INSTALLSOURCE __TEXT("InstallSource")
#define INSTALLPROPERTY_INSTALLDATE __TEXT("InstallDate")
#define INSTALLPROPERTY_PUBLISHER __TEXT("Publisher")
#define INSTALLPROPERTY_LOCALPACKAGE __TEXT("LocalPackage")
#define INSTALLPROPERTY_URLINFOABOUT __TEXT("URLInfoAbout")
#define INSTALLPROPERTY_URLUPDATEINFO __TEXT("URLUpdateInfo")
#define INSTALLPROPERTY_VERSIONMINOR __TEXT("VersionMinor")
#define INSTALLPROPERTY_VERSIONMAJOR __TEXT("VersionMajor")
typedef enum tagINSTALLTYPE
{
INSTALLTYPE_DEFAULT = 0, // set to indicate default behavior
INSTALLTYPE_NETWORK_IMAGE = 1, // set to indicate network install
}INSTALLTYPE;
#ifdef __cplusplus
extern "C" {
#endif
// --------------------------------------------------------------------------
// Functions to set the UI handling and logging. The UI will be used for error,
// progress, and log messages for all subsequent calls to Installer Service
// API functions that require UI.
// --------------------------------------------------------------------------
// Enable internal UI
INSTALLUILEVEL WINAPI MsiSetInternalUI(
INSTALLUILEVEL dwUILevel, // UI level
HWND *phWnd); // handle of owner window
// Enable external UI handling, returns any previous handler or NULL if none.
// Messages are designated with a combination of bits from INSTALLLOGMODE enum.
INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(
INSTALLUI_HANDLERA puiHandler, // for progress and error handling
DWORD dwMessageFilter, // bit flags designating messages to handle
LPVOID pvContext); // application context
INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(
INSTALLUI_HANDLERW puiHandler, // for progress and error handling
DWORD dwMessageFilter, // bit flags designating messages to handle
LPVOID pvContext); // application context
#ifdef UNICODE
#define MsiSetExternalUI MsiSetExternalUIW
#else
#define MsiSetExternalUI MsiSetExternalUIA
#endif // !UNICODE
// Enable logging to a file for all install sessions for the client process,
// with control over which log messages are passed to the specified log file.
// Messages are designated with a combination of bits from INSTALLLOGMODE enum.
UINT WINAPI MsiEnableLogA(
DWORD dwLogMode, // bit flags designating operations to report
LPCSTR szLogFile, // log file, or NULL to disable logging
DWORD dwLogAttributes); // INSTALLLOGATTRIBUTES flags
UINT WINAPI MsiEnableLogW(
DWORD dwLogMode, // bit flags designating operations to report
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -