public MsiRecord_Directories GetRecord_Directories() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "GetRecord_Directories"); MsiRecord_Directories result = new MsiRecord_Directories(); try { MsiRecords records = this.ExecuteQuery("SELECT * FROM `Directory`"); foreach (MsiRecord record in records) { if (record.Count == 3) { MsiRecord_Directory file = new MsiRecord_Directory() { Directory = record[0], ParentDirectory = record[1], DefaultPath = new MsiFieldParts(record[2]), }; result.Add(file); } } result = new MsiRecord_Directories((from r in result orderby r.Directory select r)); } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
public MsiRecords ExecuteQuery(string query) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Method"); MsiRecords result = new MsiRecords(); if (_fileHandle == IntPtr.Zero) { return(result); } try { IntPtr viewHandle = IntPtr.Zero; IntPtr recHandle = IntPtr.Zero; int hr = MsiNativeHelper.MsiDatabaseOpenView(_fileHandle, query, ref viewHandle); if (hr == 0) { hr = MsiNativeHelper.MsiViewExecute(viewHandle, IntPtr.Zero); if (hr == 0) { while ((hr = MsiNativeHelper.MsiViewFetch(viewHandle, ref recHandle)) != MsiNativeHelper.ERROR_NO_MORE_ITEMS) { if (recHandle != IntPtr.Zero) { int fields = MsiNativeHelper.MsiRecordGetFieldCount(recHandle); if (fields > 0) { MsiRecord record = new MsiRecord(); for (int i = 1; i <= fields; i++) { int len = 255; StringBuilder sb = new StringBuilder(len); hr = MsiNativeHelper.MsiRecordGetString(recHandle, i, sb, ref len); if (hr == 0) { record.Add(sb.ToString()); } } result.Add(record); } MsiNativeHelper.MsiCloseHandle(recHandle); } } } } if (viewHandle != IntPtr.Zero) { MsiNativeHelper.MsiCloseHandle(viewHandle); } } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
public MsiRecord_Files GetRecord_Files() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "GetRecord_Files"); MsiRecord_Files result = new MsiRecord_Files(); try { MsiRecords records = this.ExecuteQuery("SELECT * FROM `File`"); foreach (MsiRecord record in records) { if (record.Count == 8) { MsiRecord_File file = new MsiRecord_File() { File = record[0], Component = record[1], FileName = new MsiFieldParts(record[2]), FileSize = TypeSystem.GetValueInt64(record[3]), Version = record[4], Language = record[5], Attributes = record[6], Sequence = TypeSystem.GetValueInt64(record[7]), }; result.Add(file); } } result = new MsiRecord_Files((from r in result orderby r.File select r)); } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }