(NET) NET (2006 год)

WinDump - фиксация состояния системы. Сгрузить MSI-файл.

У меня постоянно возникает желание понять, отчего же иногда меняется состояние системы и кто его меняет. Несмотря на NET2, с кошмаром DLL положение не улучшилось, а только ухудшилось. Например, я работал-работал на своей девелоперской машине, но в какой-о момент какое-то приложение внесло странное изменнение в GAC, В результате чего моя сборка Microsoft.Visual.Basic из версии 8.0.0.0 превратилась в версию 2.0.0.1. Это привело просто к фантастическим последствиям.


Поэтому я решил раз и навсегда разрубить этот гордеев узел и создать утилиту с открытым исходным кодом, примерно аналогичную TripWire, которая бы фиксировала состояние системы и позволяла бы оценить хотя бы кто именно внес в систему изменение, ну и дополнительно решить множество сопуствуюих вопросов:


Моя прога основана на следующих технологиях:

Все это, а также примеры испоьзования System.Envirinment, System.Diagnostic и многих других классов вы можете увидеть в моем коде. Теперь еще несоколько замечаний по каждой из примененной технологии.


Общую структуру WMI-классов я знаю достаточно давно, но сейчас появились интересные средства для более быстрой работы - утилита WMIC, например. С ее помощью я получил описания нескольких интересных классов WMI:

Затем я создал из определений этих классов обьекты на VB.NET и соответствующие структуры в SQL.

Но наиболее сложным для меня вопросом в этой программе оказался вопрос правильной привязки типа из динамически загружаемой библиотеки. Хотя я имею приличный опыт работы с System.Reflectiom - например делал динамическую подзагрузку типов с анализом и динамическим формированием их параметров, мне пришлось проштудировать и вот эту книгу и все в MSDN по Reflection.

В процессе написания этой проги я также испробовал несколько техник обращения к fusion.dll - менеджеру GAC'а, пока не остановился на классах из Microsoft.CLRAdmin. Вариант прямого обращения к Fusion.Dll лежит здесь.

Что касается подсчета ХЕШ-кодов, то мои тесты показали, что MD5-хеш - наиболее быстрый из известных ХЕШ-алгоритмов. Ему немного проигрывает по скорости SHA1, который также имеет более длинных ХЕШ - 20 байт вместо 16.


Итак, принцип работы моей проги я думаю, понятен. Теперь пару слов о технике реализации. Собственно, эта утилита просто дампирует состояние системы в базу, поэтому в качестве интерфейса я выбрал командную строку. Средства построения отчетов полностью отделены от проги собственно записи данных в базу. Саму утилиту я разбил на два EXE-файла. Один WinDump - собственно сохраняет состояние системы в базу, а второй WinDumpSet вызывается до начала основной работы и принимает один параметр в кавычках - строка подключения к SQL. В SQL надо на этот момент уже создать базу, но без таблиц. Таблицы создает WinDumpSet и он же запоминает в реестре строку подключения, к которой потом при работе обращается WinDump.

В тексте я применил все возможности подсказки VS2005, что облегчает программирование и отладку - как вы видите на рисунке. Приличное время работы проги определяется тем, что на моем девелоперском кампе четыре диска (в том числе большие - 320 Гигабайт) и плюс, у меня несколько виртуальных машин, размеры файлов которых около 20 Гигабайт (а MD5-хеши таких файлов, значительно превышающих размер ОЗУ, считаются ой как небыстро).




Инсталляционный проект этой проги (который вы видите на рисунка) описан здесь. А теперь собственно код инициализирующей программы WinDumpSet:

00001: Module WinDumpSet
00002: 
00003:     Dim CN As New SqlClient.SqlConnection("")   '"Data Source=VS2005;Initial Catalog=ScanDisk1;Integrated Security=True"
00004:     'табла для запоминания состояния файлов на дисках
00005:     Dim CMD_CR1 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00006:     "CREATE TABLE [dbo].[MyFile](" & _
00007:     "[i] [int] IDENTITY(1,1) NOT NULL," & _
00008:     "[Dir] [nvarchar](450) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL," & _
00009:     "[FileName] [nvarchar](450) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00010:     "[CreationTime] [datetime] NULL," & _
00011:     "[LastWriteTime] [datetime] NULL," & _
00012:     "[Length] [bigint] NULL," & _
00013:     "[MD5] [binary](16) NULL," & _
00014:     "[Date] [datetime]  NOT NULL," & _
00015:     "[ToLast] [int] NULL," & _
00016:     "[Num] [int] NOT NULL" & _
00017:     ") ON [PRIMARY];" & _
00018:     "CREATE NONCLUSTERED INDEX [Dir] ON [dbo].[MyFile] ([Dir] ASC)")
00019: 
00020:     'ПРИМЕЧАНИЯ:
00021:     'FileName, Length, MD5 = NULL для директорий
00022:     'Length и MD5 = NULL для занятых файлов
00023:     'ToFile - ссылка на предыдущее состояние этого же файла
00024:     'Длина имен 450 - с запасом, реально 256. (900 байт максмимальная длина поля для построения индекса).
00025:     'Для SHA1 длина поля с хешем - 20 байт
00026: 
00027:     'табла для запоминания сборок, установленных в GAC
00028:     Dim CMD_CR2 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00029:       "CREATE TABLE [dbo].[MyGAC](" & _
00030:      "[i] [int] IDENTITY(1,1) NOT NULL," & _
00031:      "[Name] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL," & _
00032:      "[Version] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00033:      "[FullName] [nvarchar](450) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL," & _
00034:      "[Date] [datetime] NOT NULL," & _
00035:      "[ToLast] [int] NULL," & _
00036:      "[Num] [int] NOT NULL" & _
00037:      ") ON [PRIMARY];" & _
00038:      "CREATE NONCLUSTERED INDEX [GAC] ON [dbo].[MyGAC] ([FullName] ASC)")
00039: 
00040:     'табла для запоминания инсталлированных пакетов программ
00041:     Dim CMD_CR3 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00042:     "CREATE TABLE [dbo].[MySoft](" & _
00043:     "[i] [int] IDENTITY(1,1) NOT NULL," & _
00044:     "[Accesses] [smallint] NULL," & _
00045:     "[Attributes] [smallint] NULL," & _
00046:     "[Caption] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00047:     "[Description] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00048:     "[IdentifyingNumber] [nvarchar](38) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00049:     "[InstallDate] [datetime] NULL," & _
00050:     "[InstallState] [smallint] NULL," & _
00051:     "[LastUse] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00052:     "[Name] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00053:     "[ProductName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00054:     "[Status] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00055:     "[Vendor] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00056:     "[Version] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00057:     "[Date] [datetime] NULL," & _
00058:     "[ToLast] [int] NULL," & _
00059:     "[Num] [int] NULL" & _
00060:     ") ON [PRIMARY];" & _
00061:     "CREATE NONCLUSTERED INDEX [Soft] ON [dbo].[MySoft] ([IdentifyingNumber] ASC)")
00062: 
00063:     'табла для фиксации COM-обьектов системы
00064:     Dim CMD_CR4 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00065:     "CREATE TABLE [dbo].[MyCOM](" & _
00066:     "[i] [int] IDENTITY(1,1) NOT NULL," & _
00067:     "[AppID] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00068:     "[AutoConvertToClsid] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00069:     "[AutoTreatAsClsid] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00070:     "[Caption] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00071:     "[ComponentId] [nvarchar](38) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00072:     "[Control] [bit] NULL," & _
00073:     "[DefaultIcon] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00074:     "[Description] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00075:     "[InprocHandler] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00076:     "[InprocHandler32] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00077:     "[InprocServer] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00078:     "[InprocServer32] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00079:     "[Insertable] [bit] NULL," & _
00080:     "[JavaClass] [bit] NULL," & _
00081:     "[LocalServer] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00082:     "[LocalServer32] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00083:     "[LongDisplayName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00084:     "[ProgId] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00085:     "[SettingID] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00086:     "[ShortDisplayName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00087:     "[ThreadingModel] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00088:     "[ToolBoxBitmap32] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00089:     "[TreatAsClsid] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00090:     "[TypeLibraryId] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00091:     "[Version] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00092:     "[VersionIndependentProgId] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00093:     "[Date] [datetime] NOT NULL," & _
00094:     "[ToLast] [int] NULL," & _
00095:     "[Num] [int] NOT NULL" & _
00096:     ") ON [PRIMARY];" & _
00097:     "CREATE NONCLUSTERED INDEX [COM] ON [dbo].[MyCOM] ([ComponentId] ASC)")
00098: 
00099:     'Табла для запоминания установленных хотфиксов
00100:     Dim CMD_CR5 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00101:     "CREATE TABLE [dbo].[MyHotfix](" & _
00102:     "[i] [int] IDENTITY(1,1) NOT NULL," & _
00103:     "[Caption] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00104:     "[CSName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00105:     "[Description] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00106:     "[FixComments] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00107:     "[HotFixID] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00108:     "[InstallDate] [datetime] NULL," & _
00109:     "[InstalledBy] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00110:     "[InstalledOn] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00111:     "[Name] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00112:     "[ServicePackInEffect] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00113:     "[Status] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00114:     "[Date] [datetime] NOT NULL," & _
00115:     "[ToLast] [int] NULL," & _
00116:     "[Num] [int] NOT NULL" & _
00117:     ") ON [PRIMARY]")
00118: 
00119:     'Драйвера, инсталированные в системе
00120:     Dim CMD_CR6 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00121:     "CREATE TABLE [dbo].[MyDRV](" & _
00122:     "[i] [int] IDENTITY(1,1) NOT NULL," & _
00123:     "[AcceptPause] [bit] NULL," & _
00124:     "[AcceptStop] [bit] NULL," & _
00125:     "[Caption] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00126:     "[CreationClassName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00127:     "[Description] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00128:     "[DesktopInteract] [bit] NULL," & _
00129:     "[DisplayName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00130:     "[ErrorControl] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00131:     "[ExitCode] [int] NULL," & _
00132:     "[InstallDate] [datetime] NULL," & _
00133:     "[Name] [nvarchar](158) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00134:     "[PathName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00135:     "[ServiceSpecificExitCode] [int] NULL," & _
00136:     "[ServiceType] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00137:     "[Started] [bit] NULL," & _
00138:     "[StartMode] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00139:     "[StartName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00140:     "[State] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00141:     "[Status] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00142:     "[SystemCreationClassName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00143:     "[SystemName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00144:     "[TagId] [int] NULL," & _
00145:     "[Date] [datetime] NOT NULL," & _
00146:     "[ToLast] [int] NULL," & _
00147:     "[Num] [int] NOT NULL" & _
00148:     ") ON [PRIMARY];" & _
00149:     "CREATE NONCLUSTERED INDEX [DRV] ON [dbo].[MyDRV] ([Name] ASC)")
00150: 
00151:     'Драйвера, инсталированные в системе
00152:     Dim CMD_CR7 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00153:     "CREATE TABLE [dbo].[MyServ](" & _
00154:     "[i] [int] IDENTITY(1,1) NOT NULL," & _
00155:     "[AcceptPause] [bit] NULL," & _
00156:     "[AcceptStop] [bit] NULL," & _
00157:     "[Caption] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00158:     "[CheckPoint] [int] NULL," & _
00159:     "[CreationClassName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00160:     "[Description] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00161:     "[DesktopInteract] [bit] NULL," & _
00162:     "[DisplayName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00163:     "[ErrorControl] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00164:     "[ExitCode] [int] NULL," & _
00165:     "[InstallDate] [datetime] NULL," & _
00166:     "[Name] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00167:     "[PathName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00168:     "[ProcessId] [int] NULL," & _
00169:     "[ServiceSpecificExitCode] [int] NULL," & _
00170:     "[ServiceType] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00171:     "[Started] [bit] NULL," & _
00172:     "[StartMode] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00173:     "[StartName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00174:     "[State] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00175:     "[Status] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00176:     "[SystemCreationClassName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00177:     "[SystemName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
00178:     "[TagId] [int] NULL," & _
00179:     "[WaitHint] [int] NULL," & _
00180:     "[Date] [datetime] NOT NULL," & _
00181:     "[ToLast] [int] NULL," & _
00182:     "[Num] [int] NOT NULL" & _
00183:     ") ON [PRIMARY];" & _
00184:     "CREATE NONCLUSTERED INDEX [SRV] ON [dbo].[MyServ] ([Name] ASC)")
00185: 
00186:     Sub Main()
00187:         Console.WriteLine("Сканер состояния Windows (С) VBNET2000. Установка связи с SQL-сервером.")
00188:         Console.WriteLine()
00189:         Dim PRM As Collections.ObjectModel.ReadOnlyCollection(Of String)
00190:         PRM = My.Application.CommandLineArgs
00191:         If PRM.Count = 0 Or PRM.Contains("/?") Or PRM.Contains("?") Or PRM.Contains("/Help") Or PRM.Contains("Help") Or PRM.Contains("/H") Or PRM.Contains("H") Or PRM.Contains("/h") Or PRM.Contains("h") Then
00192:             Console.WriteLine("Программа принимает один параметр - строка подключения к SQL-серверу, например:")
00193:             Console.WriteLine("""Data Source=VS2005;Initial Catalog=ScanDisk;Integrated Security=True""")
00194:             Console.WriteLine("Эта строка задается ОДИН раз при первом вызове проги и запоминается в реестре.")
00195:             Console.WriteLine("При задании этой строки в указанной базе создается необходимая структура данных.")
00196:         Else
00197:             CN.ConnectionString = PRM(0)
00198:             Try
00199:                 CN.Open()
00200:             Catch ex As Exception
00201:                 Console.WriteLine("Не удалось войти в SQL-сервер: " & ex.Message)
00202:                 Console.ReadLine()
00203:                 Exit Sub
00204:             End Try
00205:             Try
00206:                 CMD_CR1.Connection = CN
00207:                 CMD_CR1.ExecuteNonQuery()
00208:                 CMD_CR2.Connection = CN
00209:                 CMD_CR2.ExecuteNonQuery()
00210:                 CMD_CR3.Connection = CN
00211:                 CMD_CR3.ExecuteNonQuery()
00212:                 CMD_CR4.Connection = CN
00213:                 CMD_CR4.ExecuteNonQuery()
00214:                 CMD_CR5.Connection = CN
00215:                 CMD_CR5.ExecuteNonQuery()
00216:                 CMD_CR6.Connection = CN
00217:                 CMD_CR6.ExecuteNonQuery()
00218:                 CMD_CR7.Connection = CN
00219:                 CMD_CR7.ExecuteNonQuery()
00220:             Catch ex As Exception
00221:                 Console.WriteLine("Не удалось создать таблицы в указанной базе: " & ex.Message)
00222:                 Console.ReadLine()
00223:                 Exit Sub
00224:             End Try
00225:             CN.Close()
00226:             Using LM As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
00227:                 Using VBN As Microsoft.Win32.RegistryKey = LM.CreateSubKey("VBNET2000")
00228:                     VBN.SetValue("WinDump_CN", PRM(0))
00229:                     VBN.SetValue("WinDump", 0)
00230:                 End Using
00231:             End Using
00232:             Console.WriteLine("Программа проинициализирована." & vbCrLf & "Выполнить запоминание состояния системы сейчас (Y/N) ?")
00233:             Dim Replay As String = Console.ReadLine()
00234:             If Replay = "Y" Or Replay = "y" Then
00235:                 System.Diagnostics.Process.Start(System.Environment.CurrentDirectory & "\WinDump.exe")
00236:             End If
00237:         End If
00238:     End Sub
00239: End Module

Теперь собственно код главной программы WinDump:
00001: Module Scandisk
00002: 
00003:     Dim CN As New SqlClient.SqlConnection(""), StartTime As Date
00004:     Dim CMD_File As CMD_File, CMD_Dir As CMD_Dir, CMD_COM As CMD_COM, CMD_DRV As CMD_DRV, CMD_GAC As CMD_GAC, CMD_Serv As CMD_Serv, CMD_Hot As CMD_Hotfix, CMD_Soft As CMD_Soft
00005: 
00006:     <ComponentModel.Description("Сканер состояния Windows (С) VBNET2000.")> _
00007:     Sub Main()
00008:         Console.WriteLine("Сканер состояния Windows (С) VBNET2000.")
00009:         Console.WriteLine()
00010:         StartTime = Now
00011:         Dim PRM As Collections.ObjectModel.ReadOnlyCollection(Of String)
00012:         PRM = My.Application.CommandLineArgs
00013:         '
00014:         If PRM.Contains("/?") Or PRM.Contains("/Help") Or PRM.Contains("/H") Or PRM.Contains("/h") Then
00015:             Console.WriteLine("Фазы работы:")
00016:             Console.WriteLine("1.Запоминает состояние GAC.")
00017:             Console.WriteLine("2.Запоминает инсталлированные программные пакеты.")
00018:             Console.WriteLine("3.Запоминает зарегистрированные COM-обьекты.")
00019:             Console.WriteLine("4.Запоминает инсталлированные хотфиксы.")
00020:             Console.WriteLine("5.Запоминает инсталлированные драйвера.")
00021:             Console.WriteLine("6.Запоминает инсталлированные службы.")
00022:             Console.WriteLine("7.Запоминает контрольные суммы файлов на всех (или только заданных) дисках.")
00023:             Console.WriteLine()
00024:             Console.WriteLine("Примечания. Эта программа только заполняет базу, но не строит отчетов.")
00025:             Console.WriteLine("Для того, чтобы подсчет контрольной суммы файлов был доступен для максимального количества файлов, запускайте программу с правами администратора.")
00026:             Console.ReadLine()
00027:         Else
00028:             '
00029:             If Not CN_Exists() Then Exit Sub
00030:             '
00031:             Console.WriteLine("1.СКАНИРОВАНИЕ GAC *********************************************")
00032:             '
00033:             'Просмотр GAC c помощью Microsoft.CLRAdmin.Fusion (Иначе через прямой вызов Fusion.dll - http://support.microsoft.com/?kbid=317540 )
00034:             Dim NET2 As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom("mscorcfg.dll")
00035:             Dim Fusion As System.Type = NET2.GetType("Microsoft.CLRAdmin.Fusion")
00036:             Dim GacAssembly As New ArrayList
00037:             Dim OutArg As Object = New Object() {GacAssembly, CType(2, UInt32)}
00038:             Fusion.InvokeMember("ReadCache", CType(314, Reflection.BindingFlags), Nothing, Nothing, OutArg)
00039:             For Each X As Object In GacAssembly
00040:                 Dim Y = New A_OneAssemblyInfo(X)
00041:                 If Not Y.Save(CMD_GAC) Then Exit For
00042:                 Y = Nothing
00043:             Next
00044:             OutArg = Nothing
00045:             GacAssembly = Nothing
00046:             Fusion = Nothing
00047:             NET2 = Nothing
00048:             '
00049:             Console.WriteLine("2.СКАНИРОВАНИЕ ПРОГРАММ ****************************************")
00050:             '
00051:             Dim Q1 As New System.Management.SelectQuery("select * from Win32_SoftwareFeature")
00052:             Dim S1 As New System.Management.ManagementObjectSearcher(Q1)
00053:             If S1 Is Nothing Then Console.WriteLine("Не удалось инициализировать WMI класс Win32_SoftwareFeature.")
00054:             For Each X As System.Management.ManagementObject In S1.Get()
00055:                 Dim Y As New A_Win32_SoftwareFeature(X)
00056:                 If Not Y.Save(CMD_Soft) Then Exit For
00057:                 Y = Nothing
00058:             Next
00059:             Q1 = Nothing
00060:             S1 = Nothing
00061:             '
00062:             Console.WriteLine("3.СКАНИРОВАНИЕ COM-обьектов ************************************")
00063:             '
00064:             Dim Q2 As New System.Management.SelectQuery("select * from Win32_ClassicCOMClassSetting")
00065:             Dim S2 As New System.Management.ManagementObjectSearcher(Q2)
00066:             If S2 Is Nothing Then Console.WriteLine("Не удалось инициализировать WMI класс Win32_ClassicCOMClassSetting.")
00067:             For Each X As System.Management.ManagementObject In S2.Get()
00068:                 Dim Y As New A_Win32_ClassicCOMClassSetting(X)
00069:                 If Not Y.Save(CMD_COM) Then Exit For
00070:                 Y = Nothing
00071:             Next
00072:             Q2 = Nothing
00073:             S2 = Nothing
00074:             '
00075:             Console.WriteLine("4.СКАНИРОВАНИЕ ХОТФИКСОВ ***************************************")
00076:             '
00077:             Dim Q3 As New System.Management.SelectQuery("select * from Win32_QuickFixEngineering")
00078:             Dim S3 As New System.Management.ManagementObjectSearcher(Q3)
00079:             If S3 Is Nothing Then
00080:                 Console.WriteLine("Не удалось инициализировать WMI класс Win32_QuickFixEngineering.")
00081:                 Console.ReadLine()
00082:             End If
00083:             For Each X As System.Management.ManagementObject In S3.Get()
00084:                 Dim Y As New A_Win32_QuickFixEngineering(X)
00085:                 If Not Y.Save(CMD_Hot) Then Exit For
00086:                 Y = Nothing
00087:             Next
00088:             Q3 = Nothing
00089:             S3 = Nothing
00090:             '
00091:             Console.WriteLine("5.СКАНИРОВАНИЕ ДРАЙВЕРОВ ***************************************")
00092:             '
00093:             Dim Q4 As New System.Management.SelectQuery("select * from Win32_SystemDriver")
00094:             Dim S4 As New System.Management.ManagementObjectSearcher(Q4)
00095:             If S4 Is Nothing Then
00096:                 Console.WriteLine("Не удалось инициализировать WMI класс Win32_SystemDriver.")
00097:                 Console.ReadLine()
00098:             End If
00099:             For Each X As System.Management.ManagementObject In S4.Get()
00100:                 Dim Y As New A_Win32_SystemDriver(X)
00101:                 If Not Y.Save(CMD_DRV) Then Exit For
00102:                 Y = Nothing
00103:             Next
00104:             Q4 = Nothing
00105:             S4 = Nothing
00106:             '
00107:             Console.WriteLine("6.СКАНИРОВАНИЕ СЛУЖБ *******************************************")
00108:             '
00109:             Dim Q5 As New System.Management.SelectQuery("select * from Win32_Service")
00110:             Dim S5 As New System.Management.ManagementObjectSearcher(Q5)
00111:             If S5 Is Nothing Then
00112:                 Console.WriteLine("Не удалось инициализировать WMI класс Win32_Service.")
00113:                 Console.ReadLine()
00114:             End If
00115:             For Each X As System.Management.ManagementObject In S5.Get()
00116:                 Dim Y As New A_Win32_Service(X)
00117:                 If Not Y.Save(CMD_Serv) Then Exit For
00118:                 Y = Nothing
00119:             Next
00120:             Q5 = Nothing
00121:             S5 = Nothing
00122:             '
00123:             Console.WriteLine("7.СКАНИРОВАНИЕ ДИСКОВ ******************************************")
00124:             '
00125:             If PRM.Count > 0 Then
00126:                 'только заданные
00127:                 For i As Integer = 0 To PRM.Count - 1
00128:                     If Not ScanDir(PRM(i).Replace("\", "").Replace(":", ":\")) Then GoTo end1
00129:                 Next
00130:             Else
00131:                 'все диски
00132:                 If Not ScanAll() Then GoTo End1
00133:             End If
00134: end1:
00135:             CN.Close()
00136:             Console.WriteLine("Завершено. Время работы " & (Now - StartTime).ToString)
00137:             Console.ReadLine()
00138:         End If
00139:     End Sub
00140: 
00141:     ''' <summary>
00142:     ''' Проверка наличия в реестре ConnectionString для этой проги (одновременно служит контролькой, что нужная табла в базе УЖЕ создана)
00143:     ''' Открытие коннекта к базе и создание экземпляров ADO.NET команд для записи в базу
00144:     ''' </summary>
00145:     Function CN_Exists() As Boolean
00146:         Dim LM, VBN As Microsoft.Win32.RegistryKey
00147:         Dim CurrentNum As Integer
00148:         Try
00149:             LM = My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE", False)
00150:             VBN = LM.OpenSubKey("VBNET2000", True)
00151:         Catch ex As Exception
00152:             Console.WriteLine("Нет доступа к реестру: " & ex.Message)
00153:             Console.ReadLine()
00154:             Return False
00155:         End Try
00156:         '
00157:         If VBN.GetValue("WinDump_CN") Is Nothing Then
00158:             Console.WriteLine("Не задан ConnectionString к базе. Предварительно следует вызвать программу WinDumpSet.exe, которой параметром задать строку подключения к SQL-серверу.")
00159:             Console.ReadLine()
00160:             Return False
00161:         Else
00162:             '
00163:             CN.ConnectionString = VBN.GetValue("WinDump_CN").ToString
00164:             VBN.SetValue("WinDump", CInt(VBN.GetValue("WinDump")) + 1)
00165:             CurrentNum = CInt(VBN.GetValue("WinDump"))
00166:             VBN.Close()
00167:             LM.Close()
00168:             '
00169:             Try
00170:                 CN.Open()
00171:             Catch ex As Exception
00172:                 Console.WriteLine("Не удалось войти в SQL-сервер: " & ex.Message)
00173:                 Console.ReadLine()
00174:                 Return False
00175:             End Try
00176:             '
00177:             Try
00178:                 CMD_File = New CMD_File(CN, CurrentNum)
00179:                 CMD_Dir = New CMD_Dir(CN, CurrentNum)
00180:                 CMD_COM = New CMD_COM(CN, CurrentNum)
00181:                 CMD_DRV = New CMD_DRV(CN, CurrentNum)
00182:                 CMD_GAC = New CMD_GAC(CN, CurrentNum)
00183:                 CMD_Serv = New CMD_Serv(CN, CurrentNum)
00184:                 CMD_Hot = New CMD_Hotfix(CN, CurrentNum)
00185:                 CMD_Soft = New CMD_Soft(CN, CurrentNum)
00186:             Catch ex As Exception
00187:                 Console.WriteLine("Не удалось инициализировать ADO.NET: " & ex.Message)
00188:                 Console.ReadLine()
00189:                 Return False
00190:             End Try
00191:             Return True
00192:         End If
00193:     End Function
00194: 
00195:     ''' <summary>
00196:     ''' Сканирование всех жестких дисков
00197:     ''' </summary>
00198:     Function ScanAll() As Boolean 'False - если возникла ошибка записи
00199:         For Each Z As System.IO.DriveInfo In My.Computer.FileSystem.Drives
00200:             If Z.DriveType.ToString = "Fixed" Then
00201:                 Console.WriteLine(Z.RootDirectory)
00202:                 If Not ScanDir(Z.RootDirectory.ToString) Then Return False
00203:             End If
00204:         Next
00205:         Return True
00206:     End Function
00207: 
00208:     ''' <summary>
00209:     ''' Рекурсивный разбор заданной директории с записью в базу
00210:     ''' </summary>
00211:     Function ScanDir(ByVal StartDir As String) As Boolean   'False - если возникла ошибка записи
00212:         Dim Start As New System.IO.DirectoryInfo(StartDir)
00213:         'В этой директории будут разобраны ВСЕ файлы и ВСЕ поддиректории
00214:         Try
00215:             For Each F As System.IO.FileInfo In Start.GetFiles
00216:                 Dim X As New A_FileInfo(F)
00217:                 If Not X.Save(CMD_File) Then Return False
00218:                 X = Nothing
00219:             Next
00220:             For Each D As System.IO.DirectoryInfo In Start.GetDirectories
00221:                 Dim X As New A_DirInfo(D)
00222:                 If Not X.Save(CMD_Dir) Then Return False
00223:                 X = Nothing
00224:                 'собственно рекурсия 
00225:                 If Not ScanDir(D.FullName) Then Return False
00226:             Next
00227:         Catch ex As Exception
00228:             'например System Volume Information не читается - не делаем ничего
00229:         End Try
00230:         Return True
00231:     End Function
00232: 
00233: End Module

Код модуля Description, содержаший описания всех классов. Как видите, эти классы не просто описывают структуру информации, выдаваемой WMI, CLRAdmin, DitInfo или FileInfo - они достаточно интеллектуальны - при создании экземпляров они выбирают из источника своей информации сведения об одном элементе - одной сборке, одном файле или одном инсталлированном пакете программ. Это как бы один момент их интлеллекта. Второй - они все содержат метод SAVE, позволяющий программе, пользующейся этими классами, за одно обращение (не вникая в детальную структуру считаной из источника данных информации - сохранить впитанный квант информации в базу.
00001: ''' <summary>
00002: ''' Структура WMI-класса Win32_SoftwareFeature
00003: ''' </summary>
00004: Friend Class A_Win32_SoftwareFeature ' : CIM_SoftwareFeature 
00005: 
00006:     Public Sub New(ByVal X As System.Management.ManagementObject)
00007:         Accesses = X.GetPropertyValue("Accesses")
00008:         Attributes = X.GetPropertyValue("Attributes")
00009:         Caption = X.GetPropertyValue("Caption")
00010:         Description = X.GetPropertyValue("Description")
00011:         IdentifyingNumber = X.GetPropertyValue("IdentifyingNumber")
00012:         InstallDate = X.GetPropertyValue("InstallDate")
00013:         InstallState = X.GetPropertyValue("InstallState")
00014:         LastUse = X.GetPropertyValue("LastUse")
00015:         Name = X.GetPropertyValue("Name")
00016:         ProductName = X.GetPropertyValue("ProductName")
00017:         Status = X.GetPropertyValue("Status")
00018:         Vendor = X.GetPropertyValue("Vendor")
00019:         Version = X.GetPropertyValue("Version")
00020:     End Sub
00021: 
00022:     Dim Accesses As UInt16
00023:     Dim Attributes As UInt16
00024:     Dim Caption As String
00025:     Dim Description As String
00026:     Dim IdentifyingNumber As String
00027:     Dim InstallDate As DateTime
00028:     Dim InstallState As UInt16
00029:     Dim LastUse As String       'тут непонятный баг
00030:     Dim Name As String
00031:     Dim ProductName As String
00032:     Dim Status As String
00033:     Dim Vendor As String
00034:     Dim Version As String
00035: 
00036:     ''' <summary>
00037:     ''' Сохранение класса Win32_SoftwareFeature в базу (True - записалось удачно)
00038:     ''' </summary>
00039:     Public Function Save(ByVal CMD As CMD_Soft) As Boolean
00040:         Return CMD.Write(Accesses, Attributes, Caption, Description, IdentifyingNumber, InstallDate, InstallState, _
00041:         LastUse, Name, ProductName, Status, Vendor, Version)
00042:     End Function
00043: 
00044: End Class
00045: 
00046: ''' <summary>
00047: ''' Структура информации о сборке в Microsoft.CLRAdmin.
00048: ''' </summary>
00049: Friend Class A_OneAssemblyInfo
00050:     ' Динамическая привязка к классу из Microsoft.CLRAdmin.AssemInfo
00051:     Public Sub New(ByVal AssemInfo As Object)
00052:         Name = AssemInfo.GetType.InvokeMember("Name", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00053:         Locale = AssemInfo.GetType.InvokeMember("Locale", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00054:         Codebase = AssemInfo.GetType.InvokeMember("Codebase", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00055:         Modified = AssemInfo.GetType.InvokeMember("Modified", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00056:         OSType = AssemInfo.GetType.InvokeMember("OSType", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00057:         OSVersion = AssemInfo.GetType.InvokeMember("OSVersion", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00058:         ProcType = AssemInfo.GetType.InvokeMember("ProcType", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00059:         PublicKey = AssemInfo.GetType.InvokeMember("PublicKey", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00060:         PublicKeyToken = AssemInfo.GetType.InvokeMember("PublicKeyToken", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00061:         Version = AssemInfo.GetType.InvokeMember("Version", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00062:         sCustom = AssemInfo.GetType.InvokeMember("sCustom", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00063:         sFusionName = AssemInfo.GetType.InvokeMember("sFusionName", (((Reflection.BindingFlags.NonPublic Or (Reflection.BindingFlags.Public Or Reflection.BindingFlags.DeclaredOnly)) Or Reflection.BindingFlags.Instance) Or Reflection.BindingFlags.GetField), Nothing, AssemInfo, Nothing)
00064:     End Sub
00065: 
00066:     Dim Name As String
00067:     Dim Locale As String
00068:     Dim Codebase As String
00069:     Dim Modified As String
00070:     Dim OSType As String
00071:     Dim OSVersion As String
00072:     Dim ProcType As String
00073:     Dim PublicKey As String
00074:     Dim PublicKeyToken As String
00075:     Dim Version As String
00076:     Dim sCustom As String
00077:     Dim sFusionName As String
00078: 
00079:     ''' <summary>
00080:     ''' Сохранение информации о сборке GAC в базу (True - запись прошла удачно)
00081:     ''' </summary>
00082:     Public Function Save(ByVal CMD As CMD_GAC) As Boolean
00083:         Return CMD.Write(Name, Version, sFusionName)
00084:     End Function
00085: 
00086: End Class
00087: 
00088: ''' <summary>
00089: ''' Описание COM-классов, зарегистрированных в системе
00090: ''' </summary>
00091: Friend Class A_Win32_ClassicCOMClassSetting ' Win32_COMSetting 
00092:     Public Sub New(ByVal X As System.Management.ManagementObject)
00093:         AppID = X.GetPropertyValue("AppID")
00094:         AutoConvertToClsid = X.GetPropertyValue("AutoConvertToClsid")
00095:         AutoTreatAsClsid = X.GetPropertyValue("AutoTreatAsClsid")
00096:         Caption = X.GetPropertyValue("Caption")
00097:         ComponentId = X.GetPropertyValue("ComponentId")
00098:         Control = X.GetPropertyValue("Control")
00099:         DefaultIcon = X.GetPropertyValue("DefaultIcon")
00100:         Description = X.GetPropertyValue("Description")
00101:         InprocHandler = X.GetPropertyValue("InprocHandler")
00102:         InprocHandler32 = X.GetPropertyValue("InprocHandler32")
00103:         InprocServer = X.GetPropertyValue("InprocServer")
00104:         InprocServer32 = X.GetPropertyValue("InprocServer32")
00105:         Insertable = X.GetPropertyValue("Insertable")
00106:         JavaClass = X.GetPropertyValue("JavaClass")
00107:         LocalServer = X.GetPropertyValue("LocalServer")
00108:         LocalServer32 = X.GetPropertyValue("LocalServer32")
00109:         LongDisplayName = X.GetPropertyValue("LongDisplayName")
00110:         ProgId = X.GetPropertyValue("ProgId")
00111:         SettingID = X.GetPropertyValue("SettingID")
00112:         ShortDisplayName = X.GetPropertyValue("ShortDisplayName")
00113:         ThreadingModel = X.GetPropertyValue("ThreadingModel")
00114:         ToolBoxBitmap32 = X.GetPropertyValue("ToolBoxBitmap32")
00115:         TreatAsClsid = X.GetPropertyValue("TreatAsClsid")
00116:         TypeLibraryId = X.GetPropertyValue("TypeLibraryId")
00117:         Version = X.GetPropertyValue("Version")
00118:         VersionIndependentProgId = X.GetPropertyValue("VersionIndependentProgId")
00119:     End Sub
00120: 
00121:     Dim AppID As String
00122:     Dim AutoConvertToClsid As String
00123:     Dim AutoTreatAsClsid As String
00124:     Dim Caption As String
00125:     Dim ComponentId As String
00126:     Dim Control As Boolean
00127:     Dim DefaultIcon As String
00128:     Dim Description As String
00129:     Dim InprocHandler As String
00130:     Dim InprocHandler32 As String
00131:     Dim InprocServer As String
00132:     Dim InprocServer32 As String
00133:     Dim Insertable As Boolean
00134:     Dim JavaClass As Boolean
00135:     Dim LocalServer As String
00136:     Dim LocalServer32 As String
00137:     Dim LongDisplayName As String
00138:     Dim ProgId As String
00139:     Dim SettingID As String
00140:     Dim ShortDisplayName As String
00141:     Dim ThreadingModel As String
00142:     Dim ToolBoxBitmap32 As String
00143:     Dim TreatAsClsid As String
00144:     Dim TypeLibraryId As String
00145:     Dim Version As String
00146:     Dim VersionIndependentProgId As String
00147: 
00148:     ''' <summary>
00149:     ''' Сохранение информациии о COM-обьекте в базу (True - запись прошла успешно)
00150:     ''' </summary>
00151:     Public Function Save(ByVal CMD As CMD_COM) As Boolean
00152:         Return CMD.Write(AppID, AutoConvertToClsid, AutoTreatAsClsid, Caption, ComponentId, Control, _
00153:                  DefaultIcon, Description, InprocHandler, InprocHandler32, InprocServer, _
00154:                  InprocServer32, Insertable, JavaClass, LocalServer, LocalServer32, LongDisplayName, _
00155:                  ProgId, SettingID, ShortDisplayName, ThreadingModel, ToolBoxBitmap32, TreatAsClsid, _
00156:                  TypeLibraryId, Version, VersionIndependentProgId)
00157:     End Function
00158: 
00159: End Class
00160: 
00161: ''' <summary>
00162: ''' Зафиксировать автоматически установленные хотфиксы
00163: ''' </summary>
00164: ''' <remarks></remarks>
00165: Friend Class A_Win32_QuickFixEngineering ' CIM_LogicalElement 
00166:     Public Sub New(ByVal x As System.Management.ManagementObject)
00167:         Caption = x.GetPropertyValue("Caption")
00168:         CSName = x.GetPropertyValue("CSName")
00169:         Description = x.GetPropertyValue("Description")
00170:         FixComments = x.GetPropertyValue("FixComments")
00171:         HotFixID = x.GetPropertyValue("HotFixID")
00172:         InstallDate = x.GetPropertyValue("InstallDate")
00173:         InstalledBy = x.GetPropertyValue("InstalledBy")
00174:         InstalledOn = x.GetPropertyValue("InstalledOn")
00175:         Name = x.GetPropertyValue("Name")
00176:         ServicePackInEffect = x.GetPropertyValue("ServicePackInEffect")
00177:         Status = x.GetPropertyValue("Status")
00178:     End Sub
00179: 
00180:     Dim Caption As String
00181:     Dim CSName As String
00182:     Dim Description As String
00183:     Dim FixComments As String
00184:     Dim HotFixID As String
00185:     Dim InstallDate As DateTime
00186:     Dim InstalledBy As String
00187:     Dim InstalledOn As String
00188:     Dim Name As String
00189:     Dim ServicePackInEffect As String
00190:     Dim Status As String
00191: 
00192:     ''' <summary>
00193:     ''' Сохранение информации о хотфиксах в базу (True - запись прошла удачно)
00194:     ''' </summary>
00195:     Public Function Save(ByVal CMD As CMD_Hotfix) As Boolean
00196:         Return CMD.Write(Caption, CSName, Description, FixComments, HotFixID, _
00197:                  InstallDate, InstalledBy, InstalledOn, Name, ServicePackInEffect, Status)
00198:     End Function
00199: 
00200: End Class
00201: 
00202: ''' <summary>
00203: ''' Все установленные в системе драйвера
00204: ''' </summary>
00205: Friend Class A_Win32_SystemDriver
00206:     Public Sub New(ByVal x As System.Management.ManagementObject)
00207:         AcceptPause = x.GetPropertyValue("AcceptPause")
00208:         AcceptStop = x.GetPropertyValue("AcceptStop")
00209:         Caption = x.GetPropertyValue("Caption")
00210:         CreationClassName = x.GetPropertyValue("CreationClassName")
00211:         Description = x.GetPropertyValue("Description")
00212:         DesktopInteract = x.GetPropertyValue("DesktopInteract")
00213:         DisplayName = x.GetPropertyValue("DisplayName")
00214:         ErrorControl = x.GetPropertyValue("ErrorControl")
00215:         ExitCode = x.GetPropertyValue("ExitCode")
00216:         InstallDate = x.GetPropertyValue("InstallDate")
00217:         Name = x.GetPropertyValue("Name")
00218:         PathName = x.GetPropertyValue("PathName")
00219:         ServiceSpecificExitCode = x.GetPropertyValue("ServiceSpecificExitCode")
00220:         ServiceType = x.GetPropertyValue("ServiceType")
00221:         Started = x.GetPropertyValue("Started")
00222:         StartMode = x.GetPropertyValue("StartMode")
00223:         StartName = x.GetPropertyValue("StartName")
00224:         State = x.GetPropertyValue("State")
00225:         Status = x.GetPropertyValue("Status")
00226:         SystemCreationClassName = x.GetPropertyValue("SystemCreationClassName")
00227:         SystemName = x.GetPropertyValue("SystemName")
00228:         TagId = x.GetPropertyValue("TagId")
00229:     End Sub
00230: 
00231:     Dim AcceptPause As Boolean
00232:     Dim AcceptStop As Boolean
00233:     Dim Caption As String
00234:     Dim CreationClassName As String
00235:     Dim Description As String
00236:     Dim DesktopInteract As Boolean
00237:     Dim DisplayName As String
00238:     Dim ErrorControl As String
00239:     Dim ExitCode As UInt32
00240:     Dim InstallDate As DateTime
00241:     Dim Name As String
00242:     Dim PathName As String
00243:     Dim ServiceSpecificExitCode As UInt32
00244:     Dim ServiceType As String
00245:     Dim Started As Boolean
00246:     Dim StartMode As String
00247:     Dim StartName As String
00248:     Dim State As String
00249:     Dim Status As String
00250:     Dim SystemCreationClassName As String
00251:     Dim SystemName As String
00252:     Dim TagId As UInt32
00253: 
00254:     ''' <summary>
00255:     ''' Сохранение информации о драйвере в базу (True - запись прошла успешно)
00256:     ''' </summary>
00257:     Public Function Save(ByVal CMD As CMD_DRV) As Boolean
00258:         Return CMD.Write(AcceptPause, AcceptStop, Caption, CreationClassName, Description, DesktopInteract, _
00259:                  DisplayName, ErrorControl, ExitCode, InstallDate, Name, PathName, _
00260:                  ServiceSpecificExitCode, ServiceType, Started, StartMode, StartName, State, _
00261:                  Status, SystemCreationClassName, SystemName, TagId)
00262:     End Function
00263: 
00264: End Class
00265: 
00266: ''' <summary>
00267: ''' Службы системы
00268: ''' </summary>
00269: Friend Class A_Win32_Service ' Win32_BaseService 
00270:     Public Sub New(ByVal x As System.Management.ManagementObject)
00271:         AcceptPause = x.GetPropertyValue("AcceptPause")
00272:         AcceptStop = x.GetPropertyValue("AcceptStop")
00273:         Caption = x.GetPropertyValue("Caption")
00274:         CheckPoint = x.GetPropertyValue("CheckPoint")
00275:         CreationClassName = x.GetPropertyValue("CreationClassName")
00276:         Description = x.GetPropertyValue("Description")
00277:         DesktopInteract = x.GetPropertyValue("DesktopInteract")
00278:         DisplayName = x.GetPropertyValue("DisplayName")
00279:         ErrorControl = x.GetPropertyValue("ErrorControl")
00280:         ExitCode = x.GetPropertyValue("ExitCode")
00281:         InstallDate = x.GetPropertyValue("InstallDate")
00282:         Name = x.GetPropertyValue("Name")
00283:         PathName = x.GetPropertyValue("PathName")
00284:         ProcessId = x.GetPropertyValue("ProcessId")
00285:         ServiceSpecificExitCode = x.GetPropertyValue("ServiceSpecificExitCode")
00286:         ServiceType = x.GetPropertyValue("ServiceType")
00287:         Started = x.GetPropertyValue("Started")
00288:         StartMode = x.GetPropertyValue("StartMode")
00289:         StartName = x.GetPropertyValue("StartName")
00290:         State = x.GetPropertyValue("State")
00291:         Status = x.GetPropertyValue("Status")
00292:         SystemCreationClassName = x.GetPropertyValue("SystemCreationClassName")
00293:         SystemName = x.GetPropertyValue("SystemName")
00294:         TagId = x.GetPropertyValue("TagId")
00295:         WaitHint = x.GetPropertyValue("WaitHint")
00296:     End Sub
00297: 
00298: 
00299:     Dim AcceptPause As Boolean
00300:     Dim AcceptStop As Boolean
00301:     Dim Caption As String
00302:     Dim CheckPoint As UInt32
00303:     Dim CreationClassName As String
00304:     Dim Description As String
00305:     Dim DesktopInteract As Boolean
00306:     Dim DisplayName As String
00307:     Dim ErrorControl As String
00308:     Dim ExitCode As UInt32
00309:     Dim InstallDate As DateTime
00310:     Dim Name As String
00311:     Dim PathName As String
00312:     Dim ProcessId As UInt32
00313:     Dim ServiceSpecificExitCode As UInt32
00314:     Dim ServiceType As String
00315:     Dim Started As Boolean
00316:     Dim StartMode As String
00317:     Dim StartName As String
00318:     Dim State As String
00319:     Dim Status As String
00320:     Dim SystemCreationClassName As String
00321:     Dim SystemName As String
00322:     Dim TagId As UInt32
00323:     Dim WaitHint As UInt32
00324: 
00325:     ''' <summary>
00326:     ''' Сохранение информации о сервисе системы (True если запись прошла успешно)
00327:     ''' </summary>
00328:     Public Function Save(ByVal CMD As CMD_Serv) As Boolean
00329:         Return CMD.Write(AcceptPause, AcceptStop, Caption, CheckPoint, CreationClassName, _
00330:                  Description, DesktopInteract, DisplayName, ErrorControl, ExitCode, _
00331:                  InstallDate, Name, PathName, ProcessId, ServiceSpecificExitCode, ServiceType, _
00332:                  Started, StartMode, StartName, State, Status, SystemCreationClassName, _
00333:                  SystemName, TagId, WaitHint)
00334:     End Function
00335: 
00336: End Class
00337: 
00338: ''' <summary>
00339: ''' Информация о директории
00340: ''' </summary>
00341: Friend Class A_DirInfo
00342: 
00343:     Public Sub New(ByVal D As System.IO.DirectoryInfo)
00344:         Dir = D.FullName
00345:         CreationTime = D.CreationTime
00346:         LastWriteTime = D.LastWriteTime
00347:     End Sub
00348: 
00349:     Dim Dir As String
00350:     Dim CreationTime As DateTime
00351:     Dim LastWriteTime As DateTime
00352: 
00353:     ''' <summary>
00354:     ''' Запись в базу информации об одной директории
00355:     ''' </summary>
00356:     Public Function Save(ByVal CMD As CMD_Dir) As Boolean
00357:         Return CMD.Write(Dir, CreationTime, LastWriteTime)
00358:     End Function
00359: End Class
00360: 
00361: ''' <summary>
00362: ''' Информация о файле
00363: ''' </summary>
00364: Friend Class A_FileInfo
00365: 
00366:     Public Sub New(ByVal F As System.IO.FileInfo)
00367:         Dir = F.FullName
00368:         FileName = F.Name
00369:         CreationTime = F.CreationTime
00370:         LastWriteTime = F.LastWriteTime
00371:         Length = F.Length
00372:         Hash = GetHash(F.FullName.ToString)
00373:     End Sub
00374: 
00375:     Dim Dir As String
00376:     Dim FileName As String
00377:     Dim CreationTime As DateTime
00378:     Dim LastWriteTime As DateTime
00379:     Dim Length As Long
00380:     Dim Hash() As Byte
00381: 
00382:     ''' <summary>
00383:     ''' Сохранение информации об одном файле (True если запись прошла удачно)
00384:     ''' </summary>
00385:     Public Function Save(ByVal CMD As CMD_File) As Boolean
00386:         Return CMD.Write(Dir, FileName, CreationTime, LastWriteTime, Length, Hash)
00387:     End Function
00388: 
00389:     ''' <summary>
00390:     ''' Расчет MD5-хеша файла - 16 байт (или нули, если файл не открывается)
00391:     ''' </summary>
00392:     Function GetHash(ByVal FileName As String) As Byte()    'SHA1 - 20 байт, но считается дольше
00393:         Try
00394:             Dim MD5 As System.Security.Cryptography.MD5 = Security.Cryptography.MD5.Create
00395:             Dim FS As New System.IO.FileStream(FileName, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
00396:             Return MD5.ComputeHash(FS)
00397:             FS.Close()
00398:         Catch ex As Exception
00399:             'занято, открыть низзя
00400:             Dim X(15) As Byte
00401:             Return X
00402:         End Try
00403:     End Function
00404: 
00405: End Class

И, наконец, последний модуль ADO.NET, содержаший тоже достаточно интеллектуальный интерфейс к ADO.NET, который получив на вход информацию из Обьекта CMD (c параметрами) формирует обращение к SQL. Как вы видите, этот код тоже достаточно интеллектуальный. При создании экземпляров этих классов (служащих интерфейсом к ADO.NET и предоставляющих классам из модуля Description высокоуровневый интерфейс Write) они сразу запоминают в себе Коннекшен и номер текущего прогона. Кроме того, они убирают пустые даты, поля со значением NULL и добавляют текущую дату. Команды SQL устроены так, что сразу же ставят ссылку на предыдущий аналогичный файл или обьект, что существенно помогает при построении дифференциальных отчетов.
00001: ''' <summary>
00002: ''' Класс сохранения файла в SQL
00003: ''' </summary>
00004: Friend Class CMD_File
00005:     'команда записи файла и параметры команды
00006:     Dim CMD_F As SqlClient.SqlCommand = New SqlClient.SqlCommand("INSERT [MyFile]([Dir],[FileName],[CreationTime],[LastWriteTime],[Length],[MD5],[Date],[ToLast],[Num]) " & _
00007:     "SELECT @Dir, @FileName, @CreationTime, @LastWriteTime, @Length, @Hash, @Date, (select top 1 [i] from [MyFile] where [Dir]=@Dir order by [i] desc),@Num")
00008:     Dim Dir_F As New SqlClient.SqlParameter("@Dir", SqlDbType.NVarChar)
00009:     Dim FileName_F As New SqlClient.SqlParameter("@FileName", SqlDbType.NVarChar)
00010:     Dim CreationTime_F As New SqlClient.SqlParameter("@CreationTime", SqlDbType.DateTime)
00011:     Dim LastWriteTime_F As New SqlClient.SqlParameter("@LastWriteTime", SqlDbType.DateTime)
00012:     Dim Length_F As New SqlClient.SqlParameter("@Length", SqlDbType.BigInt)
00013:     Dim Hash_F As New SqlClient.SqlParameter("@Hash", SqlDbType.Binary)
00014:     Dim Date_F As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
00015:     Dim Num_F As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
00016: 
00017:     Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
00018:         CMD_F.Connection = CN
00019:         CMD_F.Parameters.Add(Dir_F)
00020:         CMD_F.Parameters.Add(FileName_F)
00021:         CMD_F.Parameters.Add(CreationTime_F)
00022:         CMD_F.Parameters.Add(LastWriteTime_F)
00023:         CMD_F.Parameters.Add(Length_F)
00024:         CMD_F.Parameters.Add(Hash_F)
00025:         CMD_F.Parameters.Add(Date_F)
00026:         CMD_F.Parameters.Add(Num_F)
00027:         Num_F.Value = Num
00028:     End Sub
00029: 
00030:     ''' <summary>
00031:     ''' Собственно запись в базу. (True - запись прошла удачно)
00032:     ''' </summary>
00033:     Public Function Write(ByVal Dir As String, ByVal FileName As String, ByVal CreationTime As DateTime, ByVal LastWriteTime As DateTime, ByVal Length As Long, ByVal Hash As Byte()) As Boolean
00034:         Dir_F.Value = Dir
00035:         FileName_F.Value = FileName
00036:         Length_F.Value = Length
00037:         CreationTime_F.Value = IIf(CreationTime.ToString = "1/1/0001 12:00:00 AM", CDate("#1/1/1900#"), CreationTime)
00038:         LastWriteTime_F.Value = IIf(LastWriteTime.ToString = "1/1/0001 12:00:00 AM", CDate("#1/1/1900#"), LastWriteTime)
00039:         Hash_F.Value = Hash
00040:         Date_F.Value = Now
00041:         For Each PRM As SqlClient.SqlParameter In CMD_F.Parameters
00042:             If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
00043:         Next
00044:         Try
00045:             CMD_F.ExecuteNonQuery()
00046:             Return True
00047:         Catch ex As Exception
00048:             Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
00049:             Console.ReadLine()
00050:             Return False
00051:         End Try
00052:     End Function
00053: End Class
00054: 
00055: ''' <summary>
00056: ''' Класс сохранения директории в SQL
00057: ''' </summary>
00058: Friend Class CMD_Dir
00059:     'команда записи директории и параметры команды
00060:     Dim CMD_D As SqlClient.SqlCommand = New SqlClient.SqlCommand("INSERT [MyFile]( [Dir],[CreationTime],[LastWriteTime],[Date],[ToLast],[Num]) " & _
00061:     "SELECT  @Dir, @CreationTime, @LastWriteTime,@Date, (select top 1 [i] from [MyFile] where [Dir]=@Dir order by [i] desc),@Num")
00062:     Dim Dir_D As New SqlClient.SqlParameter("@Dir", SqlDbType.NVarChar)
00063:     Dim CreationTime_D As New SqlClient.SqlParameter("@CreationTime", SqlDbType.DateTime)
00064:     Dim LastWriteTime_D As New SqlClient.SqlParameter("@LastWriteTime", SqlDbType.DateTime)
00065:     Dim Date_D As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
00066:     Dim Num_D As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
00067: 
00068:     Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
00069:         CMD_D.Connection = CN
00070:         CMD_D.Parameters.Add(Dir_D)
00071:         CMD_D.Parameters.Add(CreationTime_D)
00072:         CMD_D.Parameters.Add(LastWriteTime_D)
00073:         CMD_D.Parameters.Add(Date_D)
00074:         CMD_D.Parameters.Add(Num_D)
00075:         Num_D.Value = Num
00076:     End Sub
00077: 
00078:     ''' <summary>
00079:     ''' Собственно запись в базу. (True - запись прошла удачно)
00080:     ''' </summary>
00081:     Public Function Write(ByVal Dir As String, ByVal CreationTime As DateTime, ByVal LastWriteTime As DateTime) As Boolean
00082:         Dir_D.Value = Dir
00083:         CreationTime_D.Value = IIf(CreationTime.ToString = "1/1/0001 12:00:00 AM", CDate("#1/1/1900#"), CreationTime)
00084:         LastWriteTime_D.Value = IIf(LastWriteTime.ToString = "1/1/0001 12:00:00 AM", CDate("#1/1/1900#"), LastWriteTime)
00085:         Date_D.Value = Now
00086:         For Each PRM As SqlClient.SqlParameter In CMD_D.Parameters
00087:             If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
00088:         Next
00089:         Try
00090:             CMD_D.ExecuteNonQuery()
00091:             Return True
00092:         Catch ex As Exception
00093:             Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
00094:             Console.ReadLine()
00095:             Return False
00096:         End Try
00097:     End Function
00098: 
00099: End Class
00100: 
00101: ''' <summary>
00102: ''' Класс сохранения сборки из GAC в SQL
00103: ''' </summary>
00104: Friend Class CMD_GAC
00105:     'команда записи сборки GAC и параметры команды
00106:     Dim CMD_A As SqlClient.SqlCommand = New SqlClient.SqlCommand("INSERT [MyGAC]([Name],[Version],[FullName],[Date],[ToLast],[Num]) " & _
00107:     "SELECT @Name, @Version, @FullName, @Date, (select top 1 [i] from [MyGAC] where [FullName]=@FullName order by [i] desc),@Num")
00108:     Dim Name_A As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
00109:     Dim Version_A As New SqlClient.SqlParameter("@Version", SqlDbType.NVarChar)
00110:     Dim FullName_A As New SqlClient.SqlParameter("@FullName", SqlDbType.NVarChar)
00111:     Dim Date_A As New SqlClient.SqlParameter("@Date", SqlDbType.NVarChar)
00112:     Dim Num_A As New SqlClient.SqlParameter("@Num", SqlDbType.NVarChar)
00113: 
00114:     Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
00115:         CMD_A.Connection = CN
00116:         CMD_A.Parameters.Add(Name_A)
00117:         CMD_A.Parameters.Add(Version_A)
00118:         CMD_A.Parameters.Add(FullName_A)
00119:         CMD_A.Parameters.Add(Date_A)
00120:         CMD_A.Parameters.Add(Num_A)
00121:         Num_A.Value = Num
00122:     End Sub
00123: 
00124:     ''' <summary>
00125:     ''' Собственно запись сборок GAC в базу. (True - запись прошла удачно)
00126:     ''' </summary>
00127:     Public Function Write(ByVal Name As String, ByVal Version As String, ByVal FullName As String) As Boolean
00128:         Name_A.Value = Name
00129:         Version_A.Value = Version
00130:         FullName_A.Value = FullName
00131:         Date_A.Value = Now
00132:         For Each PRM As SqlClient.SqlParameter In CMD_A.Parameters
00133:             If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
00134:         Next
00135:         Try
00136:             CMD_A.ExecuteNonQuery()
00137:             Return True
00138:         Catch ex As Exception
00139:             Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
00140:             Console.ReadLine()
00141:             Return False
00142:         End Try
00143:     End Function
00144: End Class
00145: 
00146: ''' <summary>
00147: ''' Класс сохранения службы в SQL
00148: ''' </summary>
00149: Friend Class CMD_Serv
00150: 
00151:     Dim CMD_S As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00152:     "INSERT [MyServ] ([AcceptPause] ,[AcceptStop] ,[Caption] ,[CheckPoint] ,[CreationClassName] ,[Description] ,[DesktopInteract]" & _
00153:     ",[DisplayName] ,[ErrorControl] ,[ExitCode] ,[InstallDate] ,[Name] ,[PathName] ,[ProcessId] ,[ServiceSpecificExitCode]" & _
00154:     ",[ServiceType] ,[Started] ,[StartMode] ,[StartName] ,[State] ,[Status] ,[SystemCreationClassName] ,[SystemName]" & _
00155:     ",[TagId] ,[WaitHint] ,[Date] ,[ToLast] ,[Num])" & _
00156:     "SELECT @AcceptPause, @AcceptStop, @Caption, @CheckPoint, @CreationClassName, @Description, @DesktopInteract, " & _
00157:     "@DisplayName, @ErrorControl, @ExitCode, @InstallDate, @Name, @PathName, @ProcessId, @ServiceSpecificExitCode, " & _
00158:     "@ServiceType, @Started, @StartMode, @StartName, @State, @Status, @SystemCreationClassName, @SystemName, " & _
00159:     "@TagId, @WaitHint, @Date, (select top 1 [i] from [MyServ] where [Name]=@Name order by [i] desc), @Num")
00160: 
00161:     Dim AcceptPause_S As New SqlClient.SqlParameter("@AcceptPause", SqlDbType.Bit)
00162:     Dim AcceptStop_S As New SqlClient.SqlParameter("@AcceptStop", SqlDbType.Bit)
00163:     Dim Caption_S As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
00164:     Dim CheckPoint_S As New SqlClient.SqlParameter("@CheckPoint", SqlDbType.Int)
00165:     Dim CreationClassName_S As New SqlClient.SqlParameter("@CreationClassName", SqlDbType.NVarChar)
00166:     Dim Description_S As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
00167:     Dim DesktopInteract_S As New SqlClient.SqlParameter("@DesktopInteract", SqlDbType.Bit)
00168:     Dim DisplayName_S As New SqlClient.SqlParameter("@DisplayName", SqlDbType.NVarChar)
00169:     Dim ErrorControl_S As New SqlClient.SqlParameter("@ErrorControl", SqlDbType.NVarChar)
00170:     Dim ExitCode_S As New SqlClient.SqlParameter("@ExitCode", SqlDbType.Int)
00171:     Dim InstallDate_S As New SqlClient.SqlParameter("@InstallDate", SqlDbType.DateTime)
00172:     Dim Name_S As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
00173:     Dim PathName_S As New SqlClient.SqlParameter("@PathName", SqlDbType.NVarChar)
00174:     Dim ProcessId_S As New SqlClient.SqlParameter("@ProcessId", SqlDbType.Int)
00175:     Dim ServiceSpecificExitCode_S As New SqlClient.SqlParameter("@ServiceSpecificExitCode", SqlDbType.Int)
00176:     Dim ServiceType_S As New SqlClient.SqlParameter("@ServiceType", SqlDbType.NVarChar)
00177:     Dim Started_S As New SqlClient.SqlParameter("@Started", SqlDbType.Bit)
00178:     Dim StartMode_S As New SqlClient.SqlParameter("@StartMode", SqlDbType.NVarChar)
00179:     Dim StartName_S As New SqlClient.SqlParameter("@StartName", SqlDbType.NVarChar)
00180:     Dim State_S As New SqlClient.SqlParameter("@State", SqlDbType.NVarChar)
00181:     Dim Status_S As New SqlClient.SqlParameter("@Status", SqlDbType.NVarChar)
00182:     Dim SystemCreationClassName_S As New SqlClient.SqlParameter("@SystemCreationClassName", SqlDbType.NVarChar)
00183:     Dim SystemName_S As New SqlClient.SqlParameter("@SystemName", SqlDbType.NVarChar)
00184:     Dim TagId_S As New SqlClient.SqlParameter("@TagId", SqlDbType.Int)
00185:     Dim WaitHint_S As New SqlClient.SqlParameter("@WaitHint", SqlDbType.Int)
00186:     Dim Date_S As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
00187:     Dim Num_S As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
00188: 
00189:     Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
00190:         CMD_S.Connection = CN
00191:         CMD_S.Parameters.Add(AcceptPause_S)
00192:         CMD_S.Parameters.Add(AcceptStop_S)
00193:         CMD_S.Parameters.Add(Caption_S)
00194:         CMD_S.Parameters.Add(CheckPoint_S)
00195:         CMD_S.Parameters.Add(CreationClassName_S)
00196:         CMD_S.Parameters.Add(Description_S)
00197:         CMD_S.Parameters.Add(DesktopInteract_S)
00198:         CMD_S.Parameters.Add(DisplayName_S)
00199:         CMD_S.Parameters.Add(ErrorControl_S)
00200:         CMD_S.Parameters.Add(ExitCode_S)
00201:         CMD_S.Parameters.Add(InstallDate_S)
00202:         CMD_S.Parameters.Add(Name_S)
00203:         CMD_S.Parameters.Add(PathName_S)
00204:         CMD_S.Parameters.Add(ProcessId_S)
00205:         CMD_S.Parameters.Add(ServiceSpecificExitCode_S)
00206:         CMD_S.Parameters.Add(ServiceType_S)
00207:         CMD_S.Parameters.Add(Started_S)
00208:         CMD_S.Parameters.Add(StartMode_S)
00209:         CMD_S.Parameters.Add(StartName_S)
00210:         CMD_S.Parameters.Add(State_S)
00211:         CMD_S.Parameters.Add(Status_S)
00212:         CMD_S.Parameters.Add(SystemCreationClassName_S)
00213:         CMD_S.Parameters.Add(SystemName_S)
00214:         CMD_S.Parameters.Add(TagId_S)
00215:         CMD_S.Parameters.Add(WaitHint_S)
00216:         CMD_S.Parameters.Add(Date_S)
00217:         CMD_S.Parameters.Add(Num_S)
00218:         Num_S.Value = Num
00219:     End Sub
00220: 
00221:     ''' <summary>
00222:     ''' Собственно запись служб в базу. (True - запись прошла удачно)
00223:     ''' </summary>
00224:     Public Function Write(ByVal AcceptPause As Boolean, ByVal AcceptStop As Boolean, ByVal Caption As String, _
00225:     ByVal CheckPoint As Integer, ByVal CreationClassName As String, ByVal Description As String, ByVal DesktopInteract As Boolean, _
00226:     ByVal DisplayName As String, ByVal ErrorControl As String, ByVal ExitCode As Integer, ByVal InstallDate As DateTime, _
00227:     ByVal Name As String, ByVal PathName As String, ByVal ProcessId As Integer, ByVal ServiceSpecificExitCode As Integer, _
00228:     ByVal ServiceType As String, ByVal Started As Boolean, ByVal StartMode As String, ByVal StartName As String, _
00229:     ByVal State As String, ByVal Status As String, ByVal SystemCreationClassName As String, ByVal SystemName As String, _
00230:     ByVal TagId As Integer, ByVal WaitHint As Integer) As Boolean
00231:         AcceptPause_S.Value = AcceptPause
00232:         AcceptStop_S.Value = AcceptStop
00233:         Caption_S.Value = Caption
00234:         CheckPoint_S.Value = CheckPoint
00235:         CreationClassName_S.Value = CreationClassName
00236:         Description_S.Value = Description
00237:         DesktopInteract_S.Value = DesktopInteract
00238:         DisplayName_S.Value = DisplayName
00239:         ExitCode_S.Value = ExitCode
00240:         InstallDate_S.Value = IIf(InstallDate.ToString = "1/1/0001 12:00:00 AM", CDate("#1/1/1900#"), InstallDate)
00241:         Name_S.Value = Name
00242:         PathName_S.Value = PathName
00243:         ProcessId_S.Value = ProcessId
00244:         ServiceSpecificExitCode_S.Value = ServiceSpecificExitCode
00245:         ServiceType_S.Value = ServiceType
00246:         Started_S.Value = Started
00247:         StartMode_S.Value = StartMode
00248:         StartName_S.Value = StartName
00249:         State_S.Value = State
00250:         Status_S.Value = Status
00251:         SystemCreationClassName_S.Value = SystemCreationClassName
00252:         SystemName_S.Value = SystemName
00253:         WaitHint_S.Value = WaitHint
00254:         TagId_S.Value = TagId
00255:         Date_S.Value = Now
00256:         For Each PRM As SqlClient.SqlParameter In CMD_S.Parameters
00257:             If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
00258:         Next
00259:         Try
00260:             CMD_S.ExecuteNonQuery()
00261:             Return True
00262:         Catch ex As Exception
00263:             Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
00264:             Console.ReadLine()
00265:             Return False
00266:         End Try
00267:     End Function
00268: 
00269: End Class
00270: 
00271: ''' <summary>
00272: ''' Класс сохранения драйвера в SQL
00273: ''' </summary>
00274: ''' <remarks></remarks>
00275: Friend Class CMD_DRV
00276: 
00277:     Dim CMD_R As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00278:     "INSERT [MyDRV] ([AcceptPause] ,[AcceptStop] ,[Caption] ,[CreationClassName] ,[Description] ,[DesktopInteract]" & _
00279:     ",[DisplayName], [ErrorControl] ,[ExitCode] ,[InstallDate] ,[Name] ,[PathName] ,[ServiceSpecificExitCode] ,[ServiceType]" & _
00280:     ",[Started] ,[StartMode] ,[StartName] ,[State] ,[Status] ,[SystemCreationClassName] ,[SystemName]" & _
00281:     ",[TagId] ,[Date] ,[ToLast] ,[Num])" & _
00282:     "SELECT @AcceptPause, @AcceptStop, @Caption, @CreationClassName, @Description, @DesktopInteract, @DisplayName, " & _
00283:     "@ErrorControl, @ExitCode, @InstallDate, @Name, @PathName, @ServiceSpecificExitCode, @ServiceType, @Started, @StartMode, " & _
00284:     "@StartName, @State, @Status, @SystemCreationClassName, @SystemName, @TagId, @Date, (select top 1 [i] from [MyDRV] where [Name]=@Name order by [i] desc), @Num")
00285: 
00286:     Dim AcceptPause_R As New SqlClient.SqlParameter("@AcceptPause", SqlDbType.Bit)
00287:     Dim AcceptStop_R As New SqlClient.SqlParameter("@AcceptStop", SqlDbType.Bit)
00288:     Dim Caption_R As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
00289:     Dim CreationClassName_R As New SqlClient.SqlParameter("@CreationClassName", SqlDbType.NVarChar)
00290:     Dim Description_R As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
00291:     Dim DesktopInteract_R As New SqlClient.SqlParameter("@DesktopInteract", SqlDbType.Bit)
00292:     Dim DisplayName_R As New SqlClient.SqlParameter("@DisplayName", SqlDbType.NVarChar)
00293:     Dim ErrorControl_R As New SqlClient.SqlParameter("@ErrorControl", SqlDbType.NVarChar)
00294:     Dim ExitCode_R As New SqlClient.SqlParameter("@ExitCode", SqlDbType.Int)
00295:     Dim InstallDate_R As New SqlClient.SqlParameter("@InstallDate", SqlDbType.DateTime)
00296:     Dim Name_R As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
00297:     Dim PathName_R As New SqlClient.SqlParameter("@PathName", SqlDbType.NVarChar)
00298:     Dim ServiceSpecificExitCode_R As New SqlClient.SqlParameter("@ServiceSpecificExitCode", SqlDbType.Int)
00299:     Dim ServiceType_R As New SqlClient.SqlParameter("@ServiceType", SqlDbType.NVarChar)
00300:     Dim Started_R As New SqlClient.SqlParameter("@Started", SqlDbType.Bit)
00301:     Dim StartMode_R As New SqlClient.SqlParameter("@StartMode", SqlDbType.NVarChar)
00302:     Dim StartName_R As New SqlClient.SqlParameter("@StartName", SqlDbType.NVarChar)
00303:     Dim State_R As New SqlClient.SqlParameter("@State", SqlDbType.NVarChar)
00304:     Dim Status_R As New SqlClient.SqlParameter("@Status", SqlDbType.NVarChar)
00305:     Dim SystemCreationClassName_R As New SqlClient.SqlParameter("@SystemCreationClassName", SqlDbType.NVarChar)
00306:     Dim SystemName_R As New SqlClient.SqlParameter("@SystemName", SqlDbType.NVarChar)
00307:     Dim TagId_R As New SqlClient.SqlParameter("@TagId", SqlDbType.Int)
00308:     Dim Date_R As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
00309:     Dim Num_R As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
00310: 
00311: 
00312:     Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
00313:         CMD_R.Connection = CN
00314:         CMD_R.Parameters.Add(AcceptPause_R)
00315:         CMD_R.Parameters.Add(AcceptStop_R)
00316:         CMD_R.Parameters.Add(Caption_R)
00317:         CMD_R.Parameters.Add(CreationClassName_R)
00318:         CMD_R.Parameters.Add(Description_R)
00319:         CMD_R.Parameters.Add(DesktopInteract_R)
00320:         CMD_R.Parameters.Add(DisplayName_R)
00321:         CMD_R.Parameters.Add(ErrorControl_R)
00322:         CMD_R.Parameters.Add(ExitCode_R)
00323:         CMD_R.Parameters.Add(InstallDate_R)
00324:         CMD_R.Parameters.Add(Name_R)
00325:         CMD_R.Parameters.Add(PathName_R)
00326:         CMD_R.Parameters.Add(ServiceSpecificExitCode_R)
00327:         CMD_R.Parameters.Add(ServiceType_R)
00328:         CMD_R.Parameters.Add(Started_R)
00329:         CMD_R.Parameters.Add(StartMode_R)
00330:         CMD_R.Parameters.Add(StartName_R)
00331:         CMD_R.Parameters.Add(State_R)
00332:         CMD_R.Parameters.Add(Status_R)
00333:         CMD_R.Parameters.Add(SystemCreationClassName_R)
00334:         CMD_R.Parameters.Add(SystemName_R)
00335:         CMD_R.Parameters.Add(TagId_R)
00336:         CMD_R.Parameters.Add(Date_R)
00337:         CMD_R.Parameters.Add(Num_R)
00338:         Num_R.Value = Num
00339:     End Sub
00340: 
00341:     ''' <summary>
00342:     ''' Собственно запись драйверов в базу. (True - запись прошла удачно)
00343:     ''' </summary>
00344:     Public Function Write(ByVal AcceptPause As Boolean, ByVal AcceptStop As Boolean, ByVal Caption As String, ByVal CreationClassName As String, _
00345:     ByVal Description As String, ByVal DesktopInteract As Boolean, ByVal DisplayName As String, ByVal ErrorControl As String, ByVal ExitCode As Integer, _
00346:     ByVal InstallDate As DateTime, ByVal Name As String, ByVal PathName As String, ByVal ServiceSpecificExitCode As Integer, _
00347:     ByVal ServiceType As String, ByVal Started As Boolean, ByVal StartMode As String, ByVal StartName As String, ByVal State As String, _
00348:     ByVal Status As String, ByVal SystemCreationClassName As String, ByVal SystemName As String, ByVal TagId As Integer) As Boolean
00349:         AcceptPause_R.Value = AcceptPause
00350:         AcceptStop_R.Value = AcceptStop
00351:         Caption_R.Value = Caption
00352:         CreationClassName_R.Value = CreationClassName
00353:         Description_R.Value = Description
00354:         DesktopInteract_R.Value = DesktopInteract
00355:         DisplayName_R.Value = DisplayName
00356:         ErrorControl_R.value = ErrorControl
00357:         ExitCode_R.Value = ExitCode
00358:         InstallDate_R.Value = IIf(InstallDate = "1/1/0001 12:00:00 AM", CDate("#1/1/1900#"), InstallDate)
00359:         Name_R.Value = Name
00360:         PathName_R.Value = PathName
00361:         ServiceSpecificExitCode_R.Value = ServiceSpecificExitCode
00362:         ServiceType_R.Value = ServiceType
00363:         Started_R.Value = Started
00364:         StartMode_R.Value = StartMode
00365:         StartName_R.Value = StartName
00366:         State_R.Value = State
00367:         Status_R.Value = Status
00368:         SystemCreationClassName_R.Value = SystemCreationClassName
00369:         SystemName_R.Value = SystemName
00370:         TagId_R.Value = TagId
00371:         Date_R.Value = Now
00372:         For Each PRM As SqlClient.SqlParameter In CMD_R.Parameters
00373:             If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
00374:         Next
00375:         Try
00376:             CMD_R.ExecuteNonQuery()
00377:             Return True
00378:         Catch ex As Exception
00379:             Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
00380:             Console.ReadLine()
00381:             Return False
00382:         End Try
00383:     End Function
00384: 
00385: End Class
00386: 
00387: ''' <summary>
00388: ''' Класс сохранения хотфикса в SQL
00389: ''' </summary>
00390: Friend Class CMD_Hotfix
00391: 
00392:     Dim CMD_H As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00393:     "INSERT [MyHotfix]([Caption] ,[CSName] ,[Description] ,[FixComments] ,[HotFixID] ,[InstallDate] ,[InstalledBy] ,[InstalledOn]" & _
00394:     ",[Name] ,[ServicePackInEffect] ,[Status] ,[Date] ,[ToLast] ,[Num])" & _
00395:     "SELECT @Caption, @CSName, @Description, @FixComments, @HotFixID, @InstallDate, @InstalledBy, @InstalledOn, @Name, " & _
00396:     "@ServicePackInEffect, @Status, @Date, 0, @Num")
00397: 
00398:     Dim Caption_H As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
00399:     Dim CSName_H As New SqlClient.SqlParameter("@CSName", SqlDbType.NVarChar)
00400:     Dim Description_H As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
00401:     Dim FixComments_H As New SqlClient.SqlParameter("@FixComments", SqlDbType.NVarChar)
00402:     Dim HotFixID_H As New SqlClient.SqlParameter("@HotFixID", SqlDbType.NVarChar)
00403:     Dim InstallDate_H As New SqlClient.SqlParameter("@InstallDate", SqlDbType.DateTime)
00404:     Dim InstalledBy_H As New SqlClient.SqlParameter("@InstalledBy", SqlDbType.NVarChar)
00405:     Dim InstalledOn_H As New SqlClient.SqlParameter("@InstalledOn", SqlDbType.NVarChar)
00406:     Dim Name_H As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
00407:     Dim ServicePackInEffect_H As New SqlClient.SqlParameter("@ServicePackInEffect", SqlDbType.NVarChar)
00408:     Dim Status_H As New SqlClient.SqlParameter("@Status", SqlDbType.NVarChar)
00409:     Dim Date_H As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
00410:     Dim Num_H As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
00411: 
00412:     Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
00413:         CMD_H.Connection = CN
00414:         CMD_H.Parameters.Add(Caption_H)
00415:         CMD_H.Parameters.Add(CSName_H)
00416:         CMD_H.Parameters.Add(Description_H)
00417:         CMD_H.Parameters.Add(FixComments_H)
00418:         CMD_H.Parameters.Add(HotFixID_H)
00419:         CMD_H.Parameters.Add(InstallDate_H)
00420:         CMD_H.Parameters.Add(InstalledBy_H)
00421:         CMD_H.Parameters.Add(InstalledOn_H)
00422:         CMD_H.Parameters.Add(Name_H)
00423:         CMD_H.Parameters.Add(ServicePackInEffect_H)
00424:         CMD_H.Parameters.Add(Status_H)
00425:         CMD_H.Parameters.Add(Date_H)
00426:         CMD_H.Parameters.Add(Num_H)
00427:         Num_H.Value = Num
00428:     End Sub
00429: 
00430:     ''' <summary>
00431:     ''' Собственно запись хотфиксов в базу. (True - запись прошла удачно)
00432:     ''' </summary>
00433:     Public Function Write(ByVal Caption As String, ByVal CSName As String, ByVal Description As String, ByVal FixComments As String, _
00434:     ByVal HotFixID As String, ByVal InstallDate As DateTime, ByVal InstalledBy As String, ByVal InstalledOn As String, _
00435:     ByVal Name As String, ByVal ServicePackInEffect As String, ByVal Status As String) As Boolean
00436:         Caption_H.Value = Caption
00437:         CSName_H.Value = CSName
00438:         Description_H.Value = Description
00439:         FixComments_H.Value = FixComments
00440:         HotFixID_H.Value = HotFixID
00441:         InstallDate_H.Value = IIf(InstallDate.ToString = "1/1/0001 12:00:00 AM", CDate("#1/1/1900#"), InstallDate)
00442:         InstalledBy_H.Value = InstalledBy
00443:         InstalledOn_H.Value = InstalledOn
00444:         Name_H.Value = Name
00445:         ServicePackInEffect_H.Value = ServicePackInEffect
00446:         Status_H.Value = Status
00447:         Date_H.Value = Now
00448:         For Each PRM As SqlClient.SqlParameter In CMD_H.Parameters
00449:             If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
00450:         Next
00451:         Try
00452:             CMD_H.ExecuteNonQuery()
00453:             Return True
00454:         Catch ex As Exception
00455:             Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
00456:             Console.ReadLine()
00457:             Return False
00458:         End Try
00459:     End Function
00460: 
00461: End Class
00462: 
00463: ''' <summary>
00464: ''' Класс сохранения COM-обьекта в SQL
00465: ''' </summary>
00466: Friend Class CMD_COM
00467: 
00468:     Dim CMD_C As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00469:     "INSERT INTO [MyCOM] ([AppID], [AutoConvertToClsid] ,[AutoTreatAsClsid] ,[Caption] ,[ComponentId] ,[Control] ,[DefaultIcon]" & _
00470:     ",[Description] ,[InprocHandler] ,[InprocHandler32] ,[InprocServer] ,[InprocServer32] ,[Insertable] ,[JavaClass]" & _
00471:     ",[LocalServer] ,[LocalServer32] ,[LongDisplayName] ,[ProgId] ,[SettingID] ,[ShortDisplayName] ,[ThreadingModel]" & _
00472:     ",[ToolBoxBitmap32] ,[TreatAsClsid] ,[TypeLibraryId] ,[Version] ,[VersionIndependentProgId] ,[Date]" & _
00473:     ",[ToLast] ,[Num])" & _
00474:     "SELECT @AppID, @AutoConvertToClsid, @AutoTreatAsClsid ,@Caption ,@ComponentId ,@Control, @DefaultIcon, @Description" & _
00475:     ",@InprocHandler, @InprocHandler32, @InprocServer, @InprocServer32, @Insertable, @JavaClass, @LocalServer" & _
00476:     ",@LocalServer32, @LongDisplayName, @ProgId, @SettingID, @ShortDisplayName, @ThreadingModel, @ToolBoxBitmap32 " & _
00477:     ",@TreatAsClsid, @TypeLibraryId, @Version, @VersionIndependentProgId, @Date, (select top 1 [i] from [MyCOM] where [ComponentId]=@ComponentId order by [i] desc), @Num")
00478: 
00479:     Dim AppID_C As New SqlClient.SqlParameter("@AppID", SqlDbType.NVarChar)
00480:     Dim AutoConvertToClsid_C As New SqlClient.SqlParameter("@AutoConvertToClsid", SqlDbType.NVarChar)
00481:     Dim AutoTreatAsClsid_C As New SqlClient.SqlParameter("@AutoTreatAsClsid", SqlDbType.NVarChar)
00482:     Dim Caption_C As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
00483:     Dim ComponentId_C As New SqlClient.SqlParameter("@ComponentId", SqlDbType.NVarChar)
00484:     Dim Control_C As New SqlClient.SqlParameter("Control", SqlDbType.bit)
00485:     Dim DefaultIcon_C As New SqlClient.SqlParameter("@DefaultIcon", SqlDbType.NVarChar)
00486:     Dim Description_C As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
00487:     Dim InprocHandler_C As New SqlClient.SqlParameter("@InprocHandler", SqlDbType.NVarChar)
00488:     Dim InprocHandler32_C As New SqlClient.SqlParameter("@InprocHandler32", SqlDbType.NVarChar)
00489:     Dim InprocServer_C As New SqlClient.SqlParameter("@InprocServer", SqlDbType.NVarChar)
00490:     Dim InprocServer32_C As New SqlClient.SqlParameter("@InprocServer32", SqlDbType.NVarChar)
00491:     Dim Insertable_C As New SqlClient.SqlParameter("Insertable", Data.SqlDbType.Bit)
00492:     Dim JavaClass_C As New SqlClient.SqlParameter("JavaClass", SqlDbType.NVarChar)
00493:     Dim LocalServer_C As New SqlClient.SqlParameter("@LocalServer", SqlDbType.NVarChar)
00494:     Dim LocalServer32_C As New SqlClient.SqlParameter("@LocalServer32", SqlDbType.NVarChar)
00495:     Dim LongDisplayName_C As New SqlClient.SqlParameter("@LongDisplayName", SqlDbType.NVarChar)
00496:     Dim ProgId_C As New SqlClient.SqlParameter("@ProgId", SqlDbType.NVarChar)
00497:     Dim SettingID_C As New SqlClient.SqlParameter("@SettingID", SqlDbType.NVarChar)
00498:     Dim ShortDisplayName_C As New SqlClient.SqlParameter("@ShortDisplayName", SqlDbType.NVarChar)
00499:     Dim ThreadingModel_C As New SqlClient.SqlParameter("@ThreadingModel", SqlDbType.NVarChar)
00500:     Dim ToolBoxBitmap32_C As New SqlClient.SqlParameter("@ToolBoxBitmap32", SqlDbType.NVarChar)
00501:     Dim TreatAsClsid_C As New SqlClient.SqlParameter("@TreatAsClsid", SqlDbType.NVarChar)
00502:     Dim TypeLibraryId_C As New SqlClient.SqlParameter("@TypeLibraryId", SqlDbType.NVarChar)
00503:     Dim Version_C As New SqlClient.SqlParameter("@Version", SqlDbType.NVarChar)
00504:     Dim VersionIndependentProgId_C As New SqlClient.SqlParameter("@VersionIndependentProgId", SqlDbType.NVarChar)
00505:     Dim Date_C As New SqlClient.SqlParameter("Date", SqlDbType.DateTime)
00506:     Dim Num_C As New SqlClient.SqlParameter("Num", SqlDbType.Int)
00507: 
00508:     Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
00509:         CMD_C.Connection = CN
00510:         CMD_C.Parameters.Add(AppID_C)
00511:         CMD_C.Parameters.Add(AutoConvertToClsid_C)
00512:         CMD_C.Parameters.Add(AutoTreatAsClsid_C)
00513:         CMD_C.Parameters.Add(Caption_C)
00514:         CMD_C.Parameters.Add(ComponentId_C)
00515:         CMD_C.Parameters.Add(Control_C)
00516:         CMD_C.Parameters.Add(DefaultIcon_C)
00517:         CMD_C.Parameters.Add(Description_C)
00518:         CMD_C.Parameters.Add(InprocHandler_C)
00519:         CMD_C.Parameters.Add(InprocHandler32_C)
00520:         CMD_C.Parameters.Add(InprocServer_C)
00521:         CMD_C.Parameters.Add(InprocServer32_C)
00522:         CMD_C.Parameters.Add(Insertable_C)
00523:         CMD_C.Parameters.Add(JavaClass_C)
00524:         CMD_C.Parameters.Add(LocalServer_C)
00525:         CMD_C.Parameters.Add(LocalServer32_C)
00526:         CMD_C.Parameters.Add(LongDisplayName_C)
00527:         CMD_C.Parameters.Add(ProgId_C)
00528:         CMD_C.Parameters.Add(SettingID_C)
00529:         CMD_C.Parameters.Add(ShortDisplayName_C)
00530:         CMD_C.Parameters.Add(ThreadingModel_C)
00531:         CMD_C.Parameters.Add(ToolBoxBitmap32_C)
00532:         CMD_C.Parameters.Add(TreatAsClsid_C)
00533:         CMD_C.Parameters.Add(TypeLibraryId_C)
00534:         CMD_C.Parameters.Add(Version_C)
00535:         CMD_C.Parameters.Add(VersionIndependentProgId_C)
00536:         CMD_C.Parameters.Add(Date_C)
00537:         CMD_C.Parameters.Add(Num_C)
00538:         Num_C.Value = Num
00539:     End Sub
00540: 
00541:     ''' <summary>
00542:     ''' Собственно запись COM-обьектов в базу. (True - запись прошла удачно)
00543:     ''' </summary>
00544:     Public Function Write(ByVal AppID As String, ByVal AutoConvertToClsid As String, ByVal AutoTreatAsClsid As String, ByVal Caption As String, _
00545:     ByVal ComponentId As String, ByVal Control As Boolean, ByVal DefaultIcon As String, ByVal Description As String, ByVal InprocHandler As String, _
00546:     ByVal InprocHandler32 As String, ByVal InprocServer As String, ByVal InprocServer32 As String, ByVal Insertable As Boolean, _
00547:     ByVal JavaClass As String, ByVal LocalServer As String, ByVal LocalServer32 As String, ByVal LongDisplayName As String, _
00548:     ByVal ProgId As String, ByVal SettingID As String, ByVal ShortDisplayName As String, ByVal ThreadingModel As String, ByVal ToolBoxBitmap32 As String, _
00549:     ByVal TreatAsClsid As String, ByVal TypeLibraryId As String, ByVal Version As String, ByVal VersionIndependentProgId As String) As Boolean
00550:         AppID_C.Value = AppID
00551:         AutoConvertToClsid_C.Value = AutoConvertToClsid
00552:         AutoTreatAsClsid_C.Value = AutoTreatAsClsid
00553:         Caption_C.Value = Caption
00554:         ComponentId_C.Value = ComponentId
00555:         Control_C.Value = Control
00556:         DefaultIcon_C.Value = DefaultIcon
00557:         Description_C.Value = Description
00558:         InprocHandler_C.Value = InprocHandler
00559:         InprocHandler32_C.Value = InprocHandler32
00560:         InprocServer_C.Value = InprocServer
00561:         InprocServer32_C.Value = InprocServer32
00562:         Insertable_C.Value = Insertable
00563:         JavaClass_C.Value = JavaClass
00564:         LocalServer_C.Value = LocalServer
00565:         LocalServer32_C.Value = LocalServer32
00566:         LongDisplayName_C.Value = LongDisplayName
00567:         ProgId_C.Value = ProgId
00568:         SettingID_C.Value = SettingID
00569:         ShortDisplayName_C.Value = ShortDisplayName
00570:         ThreadingModel_C.Value = ThreadingModel
00571:         ToolBoxBitmap32_C.Value = ToolBoxBitmap32
00572:         TreatAsClsid_C.Value = TreatAsClsid
00573:         TypeLibraryId_C.Value = TypeLibraryId
00574:         Version_C.Value = Version
00575:         VersionIndependentProgId_C.Value = VersionIndependentProgId
00576:         Date_C.Value = Now
00577:         For Each PRM As SqlClient.SqlParameter In CMD_C.Parameters
00578:             If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
00579:         Next
00580:         Try
00581:             CMD_C.ExecuteNonQuery()
00582:             Return True
00583:         Catch ex As Exception
00584:             Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
00585:             Console.ReadLine()
00586:             Return False
00587:         End Try
00588:     End Function
00589: 
00590: End Class
00591: 
00592: ''' <summary>
00593: ''' Класс сохранения инсталлированных пакетов программ в SQL
00594: ''' </summary>
00595: Friend Class CMD_Soft
00596: 
00597:     Dim CMD_P As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
00598:     "INSERT [MySoft] ([Accesses] ,[Attributes] ,[Caption] ,[Description] ,[IdentifyingNumber] ,[InstallDate] ,[InstallState]" & _
00599:     ",[LastUse] ,[Name] ,[ProductName] ,[Status] ,[Vendor] ,[Version] ,[Date] ,[ToLast] ,[Num])" & _
00600:     "SELECT @Accesses, @Attributes, @Caption, @Description, @IdentifyingNumber, @InstallDate, @InstallState," & _
00601:     "@LastUse, @Name, @ProductName, @Status, @Vendor, @Version, @Date, (select top 1 [i] from [MySoft] where [IdentifyingNumber]=@IdentifyingNumber order by [i] desc), @Num")
00602: 
00603:     Dim Accesses_P As New SqlClient.SqlParameter("@Accesses", SqlDbType.SmallInt)
00604:     Dim Attributes_P As New SqlClient.SqlParameter("@Attributes", SqlDbType.SmallInt)
00605:     Dim Caption_P As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
00606:     Dim Description_P As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
00607:     Dim IdentifyingNumber_P As New SqlClient.SqlParameter("@IdentifyingNumber", SqlDbType.NVarChar)
00608:     Dim InstallDate_P As New SqlClient.SqlParameter("@InstallDate", SqlDbType.DateTime)
00609:     Dim InstallState_P As New SqlClient.SqlParameter("@InstallState", SqlDbType.SmallInt)
00610:     Dim LastUse_P As New SqlClient.SqlParameter("@LastUse", SqlDbType.NVarChar)
00611:     Dim Name_P As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
00612:     Dim ProductName_P As New SqlClient.SqlParameter("@ProductName", SqlDbType.NVarChar)
00613:     Dim Status_P As New SqlClient.SqlParameter("@Status", SqlDbType.NVarChar)
00614:     Dim Vendor_P As New SqlClient.SqlParameter("@Vendor", SqlDbType.NVarChar)
00615:     Dim Version_P As New SqlClient.SqlParameter("@Version", SqlDbType.NVarChar)
00616:     Dim Date_P As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
00617:     Dim Num_P As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
00618: 
00619:     Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
00620:         CMD_P.Connection = CN
00621:         CMD_P.Parameters.Add(Accesses_P)
00622:         CMD_P.Parameters.Add(Attributes_P)
00623:         CMD_P.Parameters.Add(Caption_P)
00624:         CMD_P.Parameters.Add(Description_P)
00625:         CMD_P.Parameters.Add(IdentifyingNumber_P)
00626:         CMD_P.Parameters.Add(InstallDate_P)
00627:         CMD_P.Parameters.Add(InstallState_P)
00628:         CMD_P.Parameters.Add(LastUse_P)
00629:         CMD_P.Parameters.Add(Name_P)
00630:         CMD_P.Parameters.Add(ProductName_P)
00631:         CMD_P.Parameters.Add(Status_P)
00632:         CMD_P.Parameters.Add(Vendor_P)
00633:         CMD_P.Parameters.Add(Version_P)
00634:         CMD_P.Parameters.Add(Date_P)
00635:         CMD_P.Parameters.Add(Num_P)
00636:         Num_P.Value = Num
00637:     End Sub
00638: 
00639:     ''' <summary>
00640:     ''' Собственно запись программых пакетов в базу. (True - запись прошла удачно)
00641:     ''' </summary>
00642:     Public Function Write(ByVal Accesses As UInt16, ByVal Attributes As UInt16, ByVal Caption As String, ByVal Description As String, _
00643:     ByVal IdentifyingNumber As String, ByVal InstallDate As DateTime, ByVal InstallState As UInt16, ByVal LastUse As String, _
00644:     ByVal Name As String, ByVal ProductName As String, ByVal Status As String, ByVal Vendor As String, ByVal Version As String) As Boolean
00645:         Accesses_P.Value = Accesses
00646:         Attributes_P.Value = Attributes
00647:         Caption_P.Value = Caption
00648:         Description_P.Value = Description
00649:         IdentifyingNumber_P.Value = IdentifyingNumber
00650:         InstallDate_P.Value = IIf(InstallDate.ToString = "1/1/0001 12:00:00 AM", CDate("#1/1/1900#"), InstallDate)
00651:         InstallState_P.Value = InstallState
00652:         LastUse_P.Value = LastUse
00653:         Name_P.Value = Name
00654:         ProductName_P.Value = ProductName
00655:         Status_P.Value = Status
00656:         Vendor_P.Value = Vendor
00657:         Version_P.Value = Version
00658:         Date_P.Value = Now
00659:         For Each PRM As SqlClient.SqlParameter In CMD_P.Parameters
00660:             If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
00661:         Next
00662:         Try
00663:             CMD_P.ExecuteNonQuery()
00664:             Return True
00665:         Catch ex As Exception
00666:             Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
00667:             Console.ReadLine()
00668:             Return False
00669:         End Try
00670:     End Function
00671: 
00672: End Class

Вопрос отчетов - отдельный вопрос. Особенно отчетов дифференциальных, показывающих изменения состояния системы, возникшее, скажем от установки нового пакета программ (или автоматичски устанавливаемого системой хотфикса, например). Но простейшие статические отчеты я получил с помощью нижеследующего текста на ASP2 в течении пяти минут.

00001: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
00002: 
00003: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00004: 
00005: <html xmlns="http://www.w3.org/1999/xhtml" >
00006: <head runat="server">
00007:     <title>Untitled Page</title>
00008: </head>
00009: <body>
00010:     <form id="form1" runat="server">
00011:     <div>
00012:         <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
00013:             <StaticMenuItemStyle ItemSpacing="20px" />
00014:             <Items>
00015:                 <asp:MenuItem Text="Сборки GAC" Value="0"></asp:MenuItem>
00016:                 <asp:MenuItem Text="Пакеты программ" Value="1"></asp:MenuItem>
00017:                 <asp:MenuItem Text="Com-обьекты" Value="2"></asp:MenuItem>
00018:                 <asp:MenuItem Text="Хотфиксы" Value="3"></asp:MenuItem>
00019:                 <asp:MenuItem Text="Драйвера" Value="4"></asp:MenuItem>
00020:                 <asp:MenuItem Text="Службы" Value="5"></asp:MenuItem>
00021:                 <asp:MenuItem Text="Диски" Value="6"></asp:MenuItem>
00022:             </Items>
00023:         </asp:Menu>
00024:         <asp:MultiView ID="MultiView1" runat="server">
00025:            <asp:View ID="View1" runat="server">
00026:                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EnableViewState="False">
00027:                    <Columns>
00028:                        <asp:BoundField DataField="i" HeaderText="i" InsertVisible="False" ReadOnly="True"
00029:                            SortExpression="i" />
00030:                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
00031:                        <asp:BoundField DataField="Version" HeaderText="Version" SortExpression="Version" />
00032:                        <asp:BoundField DataField="FullName" HeaderText="FullName" SortExpression="FullName" />
00033:                        <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
00034:                        <asp:BoundField DataField="ToLast" HeaderText="ToLast" SortExpression="ToLast" />
00035:                        <asp:BoundField DataField="Num" HeaderText="Num" SortExpression="Num" />
00036:                    </Columns>
00037:                </asp:GridView>
00038:                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:WinDumpConnectionString %>"
00039:                    SelectCommand="SELECT * FROM [MyGAC] WHERE ([Num] = @Num) ORDER BY [i]">
00040:                    <SelectParameters>
00041:                        <asp:ControlParameter ControlID="Label1" Name="Num" PropertyName="Text" Type="Int32" />
00042:                    </SelectParameters>
00043:                </asp:SqlDataSource>
00044:             </asp:View>
00045:             <asp:View ID="View2" runat="server">
00046:                 <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" EnableViewState="False">
00047:                     <Columns>
00048:                         <asp:BoundField DataField="i" HeaderText="i" InsertVisible="False" ReadOnly="True"
00049:                             SortExpression="i" />
00050:                         <asp:BoundField DataField="Accesses" HeaderText="Accesses" SortExpression="Accesses" />
00051:                         <asp:BoundField DataField="Attributes" HeaderText="Attributes" SortExpression="Attributes" />
00052:                         <asp:BoundField DataField="Caption" HeaderText="Caption" SortExpression="Caption" />
00053:                         <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
00054:                         <asp:BoundField DataField="IdentifyingNumber" HeaderText="IdentifyingNumber" SortExpression="IdentifyingNumber" />
00055:                         <asp:BoundField DataField="InstallDate" HeaderText="InstallDate" SortExpression="InstallDate" />
00056:                         <asp:BoundField DataField="InstallState" HeaderText="InstallState" SortExpression="InstallState" />
00057:                         <asp:BoundField DataField="LastUse" HeaderText="LastUse" SortExpression="LastUse" />
00058:                         <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
00059:                         <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
00060:                         <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
00061:                         <asp:BoundField DataField="Vendor" HeaderText="Vendor" SortExpression="Vendor" />
00062:                         <asp:BoundField DataField="Version" HeaderText="Version" SortExpression="Version" />
00063:                         <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
00064:                         <asp:BoundField DataField="ToLast" HeaderText="ToLast" SortExpression="ToLast" />
00065:                         <asp:BoundField DataField="Num" HeaderText="Num" SortExpression="Num" />
00066:                     </Columns>
00067:                 </asp:GridView>
00068:                 <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:WinDumpConnectionString %>"
00069:                     SelectCommand="SELECT * FROM [MySoft] WHERE ([Num] = @Num) ORDER BY [i]">
00070:                     <SelectParameters>
00071:                         <asp:ControlParameter ControlID="Label1" Name="Num" PropertyName="Text" Type="Int32" />
00072:                     </SelectParameters>
00073:                 </asp:SqlDataSource>
00074:             </asp:View>
00075:             <asp:View ID="View3" runat="server">
00076:                 <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:WinDumpConnectionString %>"
00077:                     SelectCommand="SELECT * FROM [MyCOM] WHERE ([Num] = @Num) ORDER BY [i]">
00078:                     <SelectParameters>
00079:                         <asp:ControlParameter ControlID="Label1" Name="Num" PropertyName="Text" Type="Int32" />
00080:                     </SelectParameters>
00081:                 </asp:SqlDataSource>
00082:                 &nbsp;
00083:                 <asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource3" EnableViewState="False">
00084:                 </asp:GridView>
00085:                 </asp:View>
00086:             <asp:View ID="View4" runat="server">
00087:                 <asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource4"
00088:                     EnableViewState="False">
00089:                     <Columns>
00090:                         <asp:BoundField DataField="i" HeaderText="i" InsertVisible="False" ReadOnly="True"
00091:                             SortExpression="i" />
00092:                         <asp:BoundField DataField="Caption" HeaderText="Caption" SortExpression="Caption" />
00093:                         <asp:BoundField DataField="CSName" HeaderText="CSName" SortExpression="CSName" />
00094:                         <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
00095:                         <asp:BoundField DataField="FixComments" HeaderText="FixComments" SortExpression="FixComments" />
00096:                         <asp:BoundField DataField="HotFixID" HeaderText="HotFixID" SortExpression="HotFixID" />
00097:                         <asp:BoundField DataField="InstallDate" HeaderText="InstallDate" SortExpression="InstallDate" />
00098:                         <asp:BoundField DataField="InstalledBy" HeaderText="InstalledBy" SortExpression="InstalledBy" />
00099:                         <asp:BoundField DataField="InstalledOn" HeaderText="InstalledOn" SortExpression="InstalledOn" />
00100:                         <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
00101:                         <asp:BoundField DataField="ServicePackInEffect" HeaderText="ServicePackInEffect"
00102:                             SortExpression="ServicePackInEffect" />
00103:                         <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
00104:                         <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
00105:                         <asp:BoundField DataField="ToLast" HeaderText="ToLast" SortExpression="ToLast" />
00106:                         <asp:BoundField DataField="Num" HeaderText="Num" SortExpression="Num" />
00107:                     </Columns>
00108:                 </asp:GridView>
00109:                 <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:WinDumpConnectionString %>"
00110:                     SelectCommand="SELECT * FROM [MyHotfix] WHERE ([Num] = @Num) ORDER BY [i]">
00111:                     <SelectParameters>
00112:                         <asp:ControlParameter ControlID="Label1" Name="Num" PropertyName="Text" Type="Int32" />
00113:                     </SelectParameters>
00114:                 </asp:SqlDataSource>
00115:             </asp:View>
00116:             <asp:View ID="View5" runat="server">
00117:                 <asp:GridView ID="GridView5" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource5"
00118:                     EnableViewState="False">
00119:                     <Columns>
00120:                         <asp:BoundField DataField="i" HeaderText="i" InsertVisible="False" ReadOnly="True"
00121:                             SortExpression="i" />
00122:                         <asp:CheckBoxField DataField="AcceptPause" HeaderText="AcceptPause" SortExpression="AcceptPause" />
00123:                         <asp:CheckBoxField DataField="AcceptStop" HeaderText="AcceptStop" SortExpression="AcceptStop" />
00124:                         <asp:BoundField DataField="Caption" HeaderText="Caption" SortExpression="Caption" />
00125:                         <asp:BoundField DataField="CreationClassName" HeaderText="CreationClassName" SortExpression="CreationClassName" />
00126:                         <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
00127:                         <asp:CheckBoxField DataField="DesktopInteract" HeaderText="DesktopInteract" SortExpression="DesktopInteract" />
00128:                         <asp:BoundField DataField="DisplayName" HeaderText="DisplayName" SortExpression="DisplayName" />
00129:                         <asp:BoundField DataField="ErrorControl" HeaderText="ErrorControl" SortExpression="ErrorControl" />
00130:                         <asp:BoundField DataField="ExitCode" HeaderText="ExitCode" SortExpression="ExitCode" />
00131:                         <asp:BoundField DataField="InstallDate" HeaderText="InstallDate" SortExpression="InstallDate" />
00132:                         <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
00133:                         <asp:BoundField DataField="PathName" HeaderText="PathName" SortExpression="PathName" />
00134:                         <asp:BoundField DataField="ServiceSpecificExitCode" HeaderText="ServiceSpecificExitCode"
00135:                             SortExpression="ServiceSpecificExitCode" />
00136:                         <asp:BoundField DataField="ServiceType" HeaderText="ServiceType" SortExpression="ServiceType" />
00137:                         <asp:CheckBoxField DataField="Started" HeaderText="Started" SortExpression="Started" />
00138:                         <asp:BoundField DataField="StartMode" HeaderText="StartMode" SortExpression="StartMode" />
00139:                         <asp:BoundField DataField="StartName" HeaderText="StartName" SortExpression="StartName" />
00140:                         <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
00141:                         <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
00142:                         <asp:BoundField DataField="SystemCreationClassName" HeaderText="SystemCreationClassName"
00143:                             SortExpression="SystemCreationClassName" />
00144:                         <asp:BoundField DataField="SystemName" HeaderText="SystemName" SortExpression="SystemName" />
00145:                         <asp:BoundField DataField="TagId" HeaderText="TagId" SortExpression="TagId" />
00146:                         <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
00147:                         <asp:BoundField DataField="ToLast" HeaderText="ToLast" SortExpression="ToLast" />
00148:                         <asp:BoundField DataField="Num" HeaderText="Num" SortExpression="Num" />
00149:                     </Columns>
00150:                 </asp:GridView>
00151:                 <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:WinDumpConnectionString %>"
00152:                     SelectCommand="SELECT * FROM [MyDRV] WHERE ([Num] = @Num) ORDER BY [i]">
00153:                     <SelectParameters>
00154:                         <asp:ControlParameter ControlID="Label1" Name="Num" PropertyName="Text" Type="Int32" />
00155:                     </SelectParameters>
00156:                 </asp:SqlDataSource>
00157:             </asp:View>
00158:             <asp:View ID="View6" runat="server">
00159:                 <asp:GridView ID="GridView6" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource6"
00160:                     EnableViewState="False">
00161:                     <Columns>
00162:                         <asp:BoundField DataField="i" HeaderText="i" InsertVisible="False" ReadOnly="True"
00163:                             SortExpression="i" />
00164:                         <asp:CheckBoxField DataField="AcceptPause" HeaderText="AcceptPause" SortExpression="AcceptPause" />
00165:                         <asp:CheckBoxField DataField="AcceptStop" HeaderText="AcceptStop" SortExpression="AcceptStop" />
00166:                         <asp:BoundField DataField="Caption" HeaderText="Caption" SortExpression="Caption" />
00167:                         <asp:BoundField DataField="CheckPoint" HeaderText="CheckPoint" SortExpression="CheckPoint" />
00168:                         <asp:BoundField DataField="CreationClassName" HeaderText="CreationClassName" SortExpression="CreationClassName" />
00169:                         <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
00170:                         <asp:CheckBoxField DataField="DesktopInteract" HeaderText="DesktopInteract" SortExpression="DesktopInteract" />
00171:                         <asp:BoundField DataField="DisplayName" HeaderText="DisplayName" SortExpression="DisplayName" />
00172:                         <asp:BoundField DataField="ErrorControl" HeaderText="ErrorControl" SortExpression="ErrorControl" />
00173:                         <asp:BoundField DataField="ExitCode" HeaderText="ExitCode" SortExpression="ExitCode" />
00174:                         <asp:BoundField DataField="InstallDate" HeaderText="InstallDate" SortExpression="InstallDate" />
00175:                         <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
00176:                         <asp:BoundField DataField="PathName" HeaderText="PathName" SortExpression="PathName" />
00177:                         <asp:BoundField DataField="ProcessId" HeaderText="ProcessId" SortExpression="ProcessId" />
00178:                         <asp:BoundField DataField="ServiceSpecificExitCode" HeaderText="ServiceSpecificExitCode"
00179:                             SortExpression="ServiceSpecificExitCode" />
00180:                         <asp:BoundField DataField="ServiceType" HeaderText="ServiceType" SortExpression="ServiceType" />
00181:                         <asp:CheckBoxField DataField="Started" HeaderText="Started" SortExpression="Started" />
00182:                         <asp:BoundField DataField="StartMode" HeaderText="StartMode" SortExpression="StartMode" />
00183:                         <asp:BoundField DataField="StartName" HeaderText="StartName" SortExpression="StartName" />
00184:                         <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
00185:                         <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
00186:                         <asp:BoundField DataField="SystemCreationClassName" HeaderText="SystemCreationClassName"
00187:                             SortExpression="SystemCreationClassName" />
00188:                         <asp:BoundField DataField="SystemName" HeaderText="SystemName" SortExpression="SystemName" />
00189:                         <asp:BoundField DataField="TagId" HeaderText="TagId" SortExpression="TagId" />
00190:                         <asp:BoundField DataField="WaitHint" HeaderText="WaitHint" SortExpression="WaitHint" />
00191:                         <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
00192:                         <asp:BoundField DataField="ToLast" HeaderText="ToLast" SortExpression="ToLast" />
00193:                         <asp:BoundField DataField="Num" HeaderText="Num" SortExpression="Num" />
00194:                     </Columns>
00195:                 </asp:GridView>
00196:                 <asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:WinDumpConnectionString %>"
00197:                     SelectCommand="SELECT * FROM [MyServ] WHERE ([Num] = @Num) ORDER BY [i]">
00198:                     <SelectParameters>
00199:                         <asp:ControlParameter ControlID="Label1" Name="Num" PropertyName="Text" Type="Int32" />
00200:                     </SelectParameters>
00201:                 </asp:SqlDataSource>
00202:             </asp:View>
00203:             <asp:View ID="View7" runat="server">
00204:                 <asp:GridView ID="GridView7" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource7"
00205:                     EnableViewState="False">
00206:                     <Columns>
00207:                         <asp:BoundField DataField="i" HeaderText="i" InsertVisible="False" ReadOnly="True"
00208:                             SortExpression="i" />
00209:                         <asp:BoundField DataField="Dir" HeaderText="Dir" SortExpression="Dir" />
00210:                         <asp:BoundField DataField="FileName" HeaderText="FileName" SortExpression="FileName" />
00211:                         <asp:BoundField DataField="CreationTime" HeaderText="CreationTime" SortExpression="CreationTime" />
00212:                         <asp:BoundField DataField="LastWriteTime" HeaderText="LastWriteTime" SortExpression="LastWriteTime" />
00213:                         <asp:BoundField DataField="Length" HeaderText="Length" SortExpression="Length" />
00214:                         <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
00215:                         <asp:BoundField DataField="ToLast" HeaderText="ToLast" SortExpression="ToLast" />
00216:                         <asp:BoundField DataField="Num" HeaderText="Num" SortExpression="Num" />
00217:                     </Columns>
00218:                 </asp:GridView>
00219:                 <asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:WinDumpConnectionString %>"
00220:                     SelectCommand="SELECT * FROM [MyFile] WHERE (([Num] = @Num) AND ([i] < @i)) ORDER BY [i]" EnableViewState="False">
00221:                     <SelectParameters>
00222:                         <asp:ControlParameter ControlID="Label1" Name="Num" PropertyName="Text" Type="Int32" />
00223:                         <asp:ControlParameter ControlID="Label2" Name="i" PropertyName="Text" Type="Int32" />
00224:                     </SelectParameters>
00225:                 </asp:SqlDataSource>
00226:             </asp:View>
00227:         </asp:MultiView></div>
00228:         <asp:Label ID="Label1" runat="server" Text="1" Visible="False"></asp:Label><asp:Label
00229:             ID="Label2" runat="server" Text="100"></asp:Label></form>
00230: </body>
00231: </html>
00001:Partial Class _Default
00002:    Inherits System.Web.UI.Page
00003:
00004:    Protected Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles Menu5.MenuItemClick
00006:        MultiView1.ActiveViewIndex = e.Item.Value
00007:    End Sub
00008:End Class

Ну и вот собственно информация моего девелоперского кампа, выгруженная отчетом, текст которого выше, после однократного прогона WinDump:

Это - так сказать, сырые отчеты. Однако сырые данные таблиц можно обработать. Например, из базы я получил вот такой список установленных на моем кампе 195 пакетов программ и вывел с помощью своей утилиты DirMSI в виде текстового файла списки установленных в мою систему файлов по каждому инсталляционному пакету.



На данный момент я (в параллель конечно к своим обычным текущим задачам), обдумываю как расширить эту прогу в части фиксации надстроек к эксплореру, с одной стороны, а с другой стороны - определить сборки в ГАК'е не только текущей версии CLR (который загружен в AppDomain), но и по всем версиям CLR, установленным на машине.

Кроме того, сюда можно было включить также фиксацию состояния базы почтовых сообщений и базы ActiveDirectory.



Комментарии к этой страничке ( )
ссылка на эту страничку: http://www.vb-net.ru/windows/WinDump/index.htm
<Назад>  <Назад>  <Назад>  <Назад>  <Назад>  <Назад>  <Назад>  <На главную>  <В раздел ASP>  <В раздел NET>  <В раздел SQL>  <В раздел Разное>  <Написать автору>  < Поблагодарить>
Московская хельсинская группа   Радио Свобода  Новая газета   The New Times (Новое время)