public void ListProducts() { int ix = 0; StringBuilder guid = new StringBuilder(64); int res = 0; while ((res = CallMsi.MsiEnumProducts(ix, guid)) == 0) { ix++; int len = 512; StringBuilder cachedmsi = new StringBuilder(len); int getprop = CallMsi.MsiGetProductInfo(guid.ToString(), CallMsi.INSTALLPROPERTY_LOCALPACKAGE, cachedmsi, ref len); if (0 == len) { continue; } len = 512; StringBuilder productname = new StringBuilder(len); getprop = CallMsi.MsiGetProductInfo(guid.ToString(), CallMsi.INSTALLPROPERTY_INSTALLEDPRODUCTNAME, productname, ref len); len = 50; StringBuilder versionstring = new StringBuilder(len); getprop = CallMsi.MsiGetProductInfo(guid.ToString(), CallMsi.INSTALLPROPERTY_VERSIONSTRING, versionstring, ref len); len = 50; StringBuilder installdate = new StringBuilder(len); getprop = CallMsi.MsiGetProductInfo(guid.ToString(), CallMsi.INSTALLPROPERTY_INSTALLDATE, installdate, ref len); GetMsiData mi = new GetMsiData(cachedmsi.ToString()); string ucode = mi.DoQuery("SELECT `Value` from `Property` WHERE `Property`.`Property` = 'UpgradeCode' "); mi.Dispose(); } }
public void ShowCompsAndClients() { int cix = 0; int res = 0; StringBuilder cguid = new StringBuilder(40); while ((res = CallMsi.MsiEnumComponents(cix, cguid)) == 0) { cix++; int pix = 0; int cres = 0; StringBuilder prodguid = new StringBuilder(40); while ((cres = CallMsi.MsiEnumClients(cguid.ToString(), pix, prodguid)) == 0) { int plen = 256; StringBuilder pname = new StringBuilder(256); int pires = CallMsi.MsiGetProductInfo(prodguid.ToString(), CallMsi.INSTALLPROPERTY_INSTALLEDPRODUCTNAME, pname, ref plen); int len = 512; StringBuilder pth = new StringBuilder(len); CallMsi.MsiGetComponentPath(prodguid.ToString(), cguid.ToString(), pth, ref len); pix++; } } }
public string DoQuery(string query) { IntPtr viewhandle = IntPtr.Zero; IntPtr nothing = IntPtr.Zero; int nres = CallMsi.MsiDatabaseOpenView(dbhandle, query, ref viewhandle); nres = CallMsi.MsiViewExecute(viewhandle, nothing); IntPtr rechandle = IntPtr.Zero; nres = CallMsi.MsiViewFetch(viewhandle, ref rechandle); if (0 != nres) // No data { CallMsi.MsiCloseHandle(viewhandle); return(null); } int outlen = 255; StringBuilder outbuff = new StringBuilder(outlen); nres = CallMsi.MsiRecordGetString(rechandle, 1, outbuff, ref outlen); int rel = CallMsi.MsiCloseHandle(viewhandle); rel = CallMsi.MsiCloseHandle(rechandle); if (0 != nres) // No data { return(null); } return(outbuff.ToString()); }
public void InternalDispose(bool disposing) { CallMsi.MsiCloseHandle(dbhandle); dbhandle = IntPtr.Zero; }
public GetMsiData(string package) { thepath = package; int nres = CallMsi.MsiOpenDatabase(thepath, null, ref dbhandle); }