| Код | class Program { public enum INSTALLSTATE { 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 }
[DllImport("msi.dll")] private static extern INSTALLSTATE MsiQueryProductState(string product);
static void Main(string[] args) { // это для примера Microsoft Visual C++ 2008 ATL Update kb973924 - x86 9.0.30729.4148 INSTALLSTATE state = MsiQueryProductState("{002D9D5E-29BA-3E6D-9BC4-3D7D6DBC735C}"); Console.WriteLine(state); } }
|
guid собственно надо взять из реестра (или из msi-ника). В реестре это HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall или HKCU аналогичная ветка ... |