WinDump - снимок состояния системы с помощью WMI.
Это одна из самых старых моих программ на WMI. Впервые я опубликовал ее в 2006-м году - и уже на тот момент ей было много лет. Но эта прога полезна и сегодняшний день - в этом году я только переставил ее с NET 2.0 на NET 4.0 и поставил скобки Try чтобы смягчить ее. По своему смыслу программа напоминает Subversion - но только она делает чек не только файловой системе, а сборкам в GAC, всем зарегистрированным в реестре COM-обьектам, всем зарегистрированным драйверам, службам, хотфиксам и установленным программам.
Все данные программа собирает с помощью WMI и сохраняет в SQL-сервер - что собственно и создает данные о состоянии системы для различных отчетных систем (которые не включены в данный OpenSource). Собранные этой программой данные могут быть использованы криминалистом даже для более качественного отслеживания состояния системы, чем позволяют SVN, CVS или Tripwire.
В инсталляцию включены две программы c консольным интерфейсом - WinDumpSet и WinDump. Первая программа создается в SQL-сервере (КоннекшенСтринг к которому указан в параметре вызова) семь табличек MyCOM, MyDRV, MyFile, MyGAC, MyHotfix,MyServ, MySoft. А вторая программа WinDump делает запросы к WMI и сохраняет все ответы в эти таблички.
WinDumpSet после создания семи рабочих табличек запоминает в реестре коннекшен-стринг к базе с дампом системы, а программа WinDump вычитывает этот коннекшен-стринг при записи в базу. Возможно это не лучшая технология - сейчас бы я так уже не писал эту прогу - но десять лет назад я делал все именно так - и переписывать сейчас работающий код мне некогда.
Учтите, что WMI иногда работает с глюками - например на скрине вы видите, как WMI отказалось давать ответы об установленных в системе программах. А раньше на этой же системе давало. Этот же эффект, думаю, наблюдал каждый - когда заходил в список установленных программ и win-оснастка при этом падала. Еще один тонкий момент - в строке 35 утилиты WinDump прописан путь к микрософтовской DLL с помощью которой фиксируется состояние GAC. У меня везде стоит NET 4.0 и 64-разряда. Для более общего случая это надо вытащить в параметры.
На последнем (седьмом) этапе фиксации состояния системы - программа проходит по всем дискам кампутера и не только учитывает все файлы, но и просчитывает MD5-хеши всех файлов - что может потребовать длительного времени (нескольких часов).
WinDumpSet (консольная утилита).
1: Module WinDumpSet
2:
3: Dim CN As New SqlClient.SqlConnection("") '"Data Source=VS2005;Initial Catalog=ScanDisk1;Integrated Security=True"
4: 'табла для запоминания состояния файлов на дисках
5: Dim CMD_CR1 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
6: "CREATE TABLE [dbo].[MyFile](" & _
7: "[i] [int] IDENTITY(1,1) NOT NULL," & _
8: "[Dir] [nvarchar](450) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL," & _
9: "[FileName] [nvarchar](450) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
10: "[CreationTime] [datetime] NULL," & _
11: "[LastWriteTime] [datetime] NULL," & _
12: "[Length] [bigint] NULL," & _
13: "[MD5] [binary](16) NULL," & _
14: "[Date] [datetime] NOT NULL," & _
15: "[ToLast] [int] NULL," & _
16: "[Num] [int] NOT NULL" & _
17: ") ON [PRIMARY];" & _
18: "CREATE NONCLUSTERED INDEX [Dir] ON [dbo].[MyFile] ([Dir] ASC)")
19:
20: 'ПРИМЕЧАНИЯ:
21: 'FileName, Length, MD5 = NULL для директорий
22: 'Length и MD5 = NULL для занятых файлов
23: 'ToFile - ссылка на предыдущее состояние этого же файла
24: 'Длина имен 450 - с запасом, реально 256. (900 байт максмимальная длина поля для построения индекса).
25: 'Для SHA1 длина поля с хешем - 20 байт
26:
27: 'табла для запоминания сборок, установленных в GAC
28: Dim CMD_CR2 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
29: "CREATE TABLE [dbo].[MyGAC](" & _
30: "[i] [int] IDENTITY(1,1) NOT NULL," & _
31: "[Name] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL," & _
32: "[Version] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
33: "[FullName] [nvarchar](450) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL," & _
34: "[Date] [datetime] NOT NULL," & _
35: "[ToLast] [int] NULL," & _
36: "[Num] [int] NOT NULL" & _
37: ") ON [PRIMARY];" & _
38: "CREATE NONCLUSTERED INDEX [GAC] ON [dbo].[MyGAC] ([FullName] ASC)")
39:
40: 'табла для запоминания инсталлированных пакетов программ
41: Dim CMD_CR3 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
42: "CREATE TABLE [dbo].[MySoft](" & _
43: "[i] [int] IDENTITY(1,1) NOT NULL," & _
44: "[Accesses] [smallint] NULL," & _
45: "[Attributes] [smallint] NULL," & _
46: "[Caption] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
47: "[Description] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
48: "[IdentifyingNumber] [nvarchar](38) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
49: "[InstallDate] [datetime] NULL," & _
50: "[InstallState] [smallint] NULL," & _
51: "[LastUse] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
52: "[Name] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
53: "[ProductName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
54: "[Status] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
55: "[Vendor] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
56: "[Version] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
57: "[Date] [datetime] NULL," & _
58: "[ToLast] [int] NULL," & _
59: "[Num] [int] NULL" & _
60: ") ON [PRIMARY];" & _
61: "CREATE NONCLUSTERED INDEX [Soft] ON [dbo].[MySoft] ([IdentifyingNumber] ASC)")
62:
63: 'табла для фиксации COM-обьектов системы
64: Dim CMD_CR4 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
65: "CREATE TABLE [dbo].[MyCOM](" & _
66: "[i] [int] IDENTITY(1,1) NOT NULL," & _
67: "[AppID] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
68: "[AutoConvertToClsid] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
69: "[AutoTreatAsClsid] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
70: "[Caption] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
71: "[ComponentId] [nvarchar](38) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
72: "[Control] [bit] NULL," & _
73: "[DefaultIcon] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
74: "[Description] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
75: "[InprocHandler] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
76: "[InprocHandler32] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
77: "[InprocServer] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
78: "[InprocServer32] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
79: "[Insertable] [bit] NULL," & _
80: "[JavaClass] [bit] NULL," & _
81: "[LocalServer] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
82: "[LocalServer32] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
83: "[LongDisplayName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
84: "[ProgId] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
85: "[SettingID] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
86: "[ShortDisplayName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
87: "[ThreadingModel] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
88: "[ToolBoxBitmap32] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
89: "[TreatAsClsid] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
90: "[TypeLibraryId] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
91: "[Version] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
92: "[VersionIndependentProgId] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
93: "[Date] [datetime] NOT NULL," & _
94: "[ToLast] [int] NULL," & _
95: "[Num] [int] NOT NULL" & _
96: ") ON [PRIMARY];" & _
97: "CREATE NONCLUSTERED INDEX [COM] ON [dbo].[MyCOM] ([ComponentId] ASC)")
98:
99: 'Табла для запоминания установленных хотфиксов
100: Dim CMD_CR5 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
101: "CREATE TABLE [dbo].[MyHotfix](" & _
102: "[i] [int] IDENTITY(1,1) NOT NULL," & _
103: "[Caption] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
104: "[CSName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
105: "[Description] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
106: "[FixComments] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
107: "[HotFixID] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
108: "[InstallDate] [datetime] NULL," & _
109: "[InstalledBy] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
110: "[InstalledOn] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
111: "[Name] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
112: "[ServicePackInEffect] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
113: "[Status] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
114: "[Date] [datetime] NOT NULL," & _
115: "[ToLast] [int] NULL," & _
116: "[Num] [int] NOT NULL" & _
117: ") ON [PRIMARY]")
118:
119: 'Драйвера, инсталированные в системе
120: Dim CMD_CR6 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
121: "CREATE TABLE [dbo].[MyDRV](" & _
122: "[i] [int] IDENTITY(1,1) NOT NULL," & _
123: "[AcceptPause] [bit] NULL," & _
124: "[AcceptStop] [bit] NULL," & _
125: "[Caption] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
126: "[CreationClassName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
127: "[Description] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
128: "[DesktopInteract] [bit] NULL," & _
129: "[DisplayName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
130: "[ErrorControl] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
131: "[ExitCode] [int] NULL," & _
132: "[InstallDate] [datetime] NULL," & _
133: "[Name] [nvarchar](158) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
134: "[PathName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
135: "[ServiceSpecificExitCode] [int] NULL," & _
136: "[ServiceType] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
137: "[Started] [bit] NULL," & _
138: "[StartMode] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
139: "[StartName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
140: "[State] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
141: "[Status] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
142: "[SystemCreationClassName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
143: "[SystemName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
144: "[TagId] [int] NULL," & _
145: "[Date] [datetime] NOT NULL," & _
146: "[ToLast] [int] NULL," & _
147: "[Num] [int] NOT NULL" & _
148: ") ON [PRIMARY];" & _
149: "CREATE NONCLUSTERED INDEX [DRV] ON [dbo].[MyDRV] ([Name] ASC)")
150:
151: 'Драйвера, инсталированные в системе
152: Dim CMD_CR7 As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
153: "CREATE TABLE [dbo].[MyServ](" & _
154: "[i] [int] IDENTITY(1,1) NOT NULL," & _
155: "[AcceptPause] [bit] NULL," & _
156: "[AcceptStop] [bit] NULL," & _
157: "[Caption] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
158: "[CheckPoint] [int] NULL," & _
159: "[CreationClassName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
160: "[Description] [nvarchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
161: "[DesktopInteract] [bit] NULL," & _
162: "[DisplayName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
163: "[ErrorControl] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
164: "[ExitCode] [int] NULL," & _
165: "[InstallDate] [datetime] NULL," & _
166: "[Name] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
167: "[PathName] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
168: "[ProcessId] [int] NULL," & _
169: "[ServiceSpecificExitCode] [int] NULL," & _
170: "[ServiceType] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
171: "[Started] [bit] NULL," & _
172: "[StartMode] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
173: "[StartName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
174: "[State] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
175: "[Status] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
176: "[SystemCreationClassName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
177: "[SystemName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," & _
178: "[TagId] [int] NULL," & _
179: "[WaitHint] [int] NULL," & _
180: "[Date] [datetime] NOT NULL," & _
181: "[ToLast] [int] NULL," & _
182: "[Num] [int] NOT NULL" & _
183: ") ON [PRIMARY];" & _
184: "CREATE NONCLUSTERED INDEX [SRV] ON [dbo].[MyServ] ([Name] ASC)")
185:
186: Sub Main()
187: Console.WriteLine("Сканер состояния Windows (С) VBNET2000. Установка связи с SQL-сервером.")
188: Console.WriteLine()
189: Dim PRM As Collections.ObjectModel.ReadOnlyCollection(Of String)
190: PRM = My.Application.CommandLineArgs
191: 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
192: Console.WriteLine("Программа принимает один параметр - строка подключения к SQL-серверу, например:")
193: Console.WriteLine("""Data Source=VS2005;Initial Catalog=ScanDisk;Integrated Security=True""")
194: Console.WriteLine("Эта строка задается ОДИН раз при первом вызове проги и запоминается в реестре.")
195: Console.WriteLine("При задании этой строки в указанной базе создается необходимая структура данных.")
196: Else
197: CN.ConnectionString = PRM(0)
198: Try
199: CN.Open()
200: Catch ex As Exception
201: Console.WriteLine("Не удалось войти в SQL-сервер: " & ex.Message)
202: Console.ReadLine()
203: Exit Sub
204: End Try
205: Try
206: CMD_CR1.Connection = CN
207: CMD_CR1.ExecuteNonQuery()
208: CMD_CR2.Connection = CN
209: CMD_CR2.ExecuteNonQuery()
210: CMD_CR3.Connection = CN
211: CMD_CR3.ExecuteNonQuery()
212: CMD_CR4.Connection = CN
213: CMD_CR4.ExecuteNonQuery()
214: CMD_CR5.Connection = CN
215: CMD_CR5.ExecuteNonQuery()
216: CMD_CR6.Connection = CN
217: CMD_CR6.ExecuteNonQuery()
218: CMD_CR7.Connection = CN
219: CMD_CR7.ExecuteNonQuery()
220: Catch ex As Exception
221: Console.WriteLine("Не удалось создать таблицы в указанной базе: " & ex.Message)
222: Console.ReadLine()
223: Exit Sub
224: End Try
225: CN.Close()
226: Using LM As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
227: Using VBN As Microsoft.Win32.RegistryKey = LM.CreateSubKey("VBNET2000")
228: VBN.SetValue("WinDump_CN", PRM(0))
229: VBN.SetValue("WinDump", 0)
230: End Using
231: End Using
232: Console.WriteLine("Программа проинициализирована." & vbCrLf & "Выполнить запоминание состояния системы сейчас (Y/N) ?")
233: Dim Replay As String = Console.ReadLine()
234: If Replay = "Y" Or Replay = "y" Then
235: System.Diagnostics.Process.Start(System.Environment.CurrentDirectory & "\WinDump.exe")
236: End If
237: End If
238: End Sub
239: End Module
WinDump - главный модуль консольной утилиты.
1: Module Scandisk
2:
3: Dim CN As New SqlClient.SqlConnection(""), StartTime As Date
4: 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
5:
6: <ComponentModel.Description("Сканер состояния Windows (С) VBNET2000.")> _
7: Sub Main()
8: Console.WriteLine("Сканер состояния Windows (С) VBNET2000.")
9: Console.WriteLine()
10: StartTime = Now
11: Dim PRM As Collections.ObjectModel.ReadOnlyCollection(Of String)
12: PRM = My.Application.CommandLineArgs
13: '
14: If PRM.Contains("/?") Or PRM.Contains("/Help") Or PRM.Contains("/H") Or PRM.Contains("/h") Then
15: Console.WriteLine("Фазы работы:")
16: Console.WriteLine("1.Запоминает состояние GAC.")
17: Console.WriteLine("2.Запоминает инсталлированные программные пакеты.")
18: Console.WriteLine("3.Запоминает зарегистрированные COM-обьекты.")
19: Console.WriteLine("4.Запоминает инсталлированные хотфиксы.")
20: Console.WriteLine("5.Запоминает инсталлированные драйвера.")
21: Console.WriteLine("6.Запоминает инсталлированные службы.")
22: Console.WriteLine("7.Запоминает контрольные суммы файлов на всех (или только заданных) дисках.")
23: Console.WriteLine()
24: Console.WriteLine("Примечания. Эта программа только заполняет базу, но не строит отчетов.")
25: Console.WriteLine("Для того, чтобы подсчет контрольной суммы файлов был доступен для максимального количества файлов, запускайте программу с правами администратора.")
26: Console.ReadLine()
27: Else
28: '
29: If Not CN_Exists() Then Exit Sub
30: '
31: Console.WriteLine("1.СКАНИРОВАНИЕ GAC *********************************************")
32: '
33: Try
34: 'Просмотр GAC c помощью Microsoft.CLRAdmin.Fusion (Иначе через прямой вызов Fusion.dll - http://support.microsoft.com/?kbid=317540 )
35: Dim NET2 As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom("C:\WINDOWS\Microsoft.NET\assembly\GAC_64\mscorcfg\v4.0_4.0.0.0__b03f5f7f11d50a3a\mscorcfg.dll")
36: Dim Fusion As System.Type = NET2.GetType("Microsoft.CLRAdmin.Fusion")
37: Dim GacAssembly As New ArrayList
38: Dim OutArg As Object = New Object() {GacAssembly, CType(2, UInt32)}
39: Fusion.InvokeMember("ReadCache", CType(314, Reflection.BindingFlags), Nothing, Nothing, OutArg)
40: For Each X As Object In GacAssembly
41: Dim Y = New A_OneAssemblyInfo(X)
42: If Not Y.Save(CMD_GAC) Then Exit For
43: Y = Nothing
44: Next
45: OutArg = Nothing
46: GacAssembly = Nothing
47: Fusion = Nothing
48: NET2 = Nothing
49: Catch ex As Exception
50: Console.WriteLine("*** ОШИБКА *** " & ex.Message)
51: End Try
52: '
53: Console.WriteLine("2.СКАНИРОВАНИЕ ПРОГРАММ ****************************************")
54: '
55: Try
56: Dim Q1 As New System.Management.SelectQuery("select * from Win32_SoftwareFeature")
57: Dim S1 As New System.Management.ManagementObjectSearcher(Q1)
58: If S1 Is Nothing Then Console.WriteLine("Не удалось инициализировать WMI класс Win32_SoftwareFeature.")
59: For Each X As System.Management.ManagementObject In S1.Get()
60: Dim Y As New A_Win32_SoftwareFeature(X)
61: If Not Y.Save(CMD_Soft) Then Exit For
62: Y = Nothing
63: Next
64: Q1 = Nothing
65: S1 = Nothing
66: Catch ex As Exception
67: Console.WriteLine("*** ОШИБКА *** " & ex.Message)
68: End Try
69: '
70: Console.WriteLine("3.СКАНИРОВАНИЕ COM-обьектов ************************************")
71: '
72: Try
73: Dim Q2 As New System.Management.SelectQuery("select * from Win32_ClassicCOMClassSetting")
74: Dim S2 As New System.Management.ManagementObjectSearcher(Q2)
75: If S2 Is Nothing Then Console.WriteLine("Не удалось инициализировать WMI класс Win32_ClassicCOMClassSetting.")
76: For Each X As System.Management.ManagementObject In S2.Get()
77: Dim Y As New A_Win32_ClassicCOMClassSetting(X)
78: If Not Y.Save(CMD_COM) Then Exit For
79: Y = Nothing
80: Next
81: Q2 = Nothing
82: S2 = Nothing
83: Catch ex As Exception
84: Console.WriteLine("*** ОШИБКА *** " & ex.Message)
85: End Try
86:
87: '
88: Console.WriteLine("4.СКАНИРОВАНИЕ ХОТФИКСОВ ***************************************")
89: '
90: Try
91: Dim Q3 As New System.Management.SelectQuery("select * from Win32_QuickFixEngineering")
92: Dim S3 As New System.Management.ManagementObjectSearcher(Q3)
93: If S3 Is Nothing Then
94: Console.WriteLine("Не удалось инициализировать WMI класс Win32_QuickFixEngineering.")
95: Console.ReadLine()
96: End If
97: For Each X As System.Management.ManagementObject In S3.Get()
98: Dim Y As New A_Win32_QuickFixEngineering(X)
99: If Not Y.Save(CMD_Hot) Then Exit For
100: Y = Nothing
101: Next
102: Q3 = Nothing
103: S3 = Nothing
104: Catch ex As Exception
105: Console.WriteLine("*** ОШИБКА *** " & ex.Message)
106: End Try
107:
108: '
109: Console.WriteLine("5.СКАНИРОВАНИЕ ДРАЙВЕРОВ ***************************************")
110: '
111: Try
112: Dim Q4 As New System.Management.SelectQuery("select * from Win32_SystemDriver")
113: Dim S4 As New System.Management.ManagementObjectSearcher(Q4)
114: If S4 Is Nothing Then
115: Console.WriteLine("Не удалось инициализировать WMI класс Win32_SystemDriver.")
116: Console.ReadLine()
117: End If
118: For Each X As System.Management.ManagementObject In S4.Get()
119: Dim Y As New A_Win32_SystemDriver(X)
120: If Not Y.Save(CMD_DRV) Then Exit For
121: Y = Nothing
122: Next
123: Q4 = Nothing
124: S4 = Nothing
125: Catch ex As Exception
126: Console.WriteLine("*** ОШИБКА *** " & ex.Message)
127: End Try
128:
129: '
130: Console.WriteLine("6.СКАНИРОВАНИЕ СЛУЖБ *******************************************")
131: '
132: Try
133: Dim Q5 As New System.Management.SelectQuery("select * from Win32_Service")
134: Dim S5 As New System.Management.ManagementObjectSearcher(Q5)
135: If S5 Is Nothing Then
136: Console.WriteLine("Не удалось инициализировать WMI класс Win32_Service.")
137: Console.ReadLine()
138: End If
139: For Each X As System.Management.ManagementObject In S5.Get()
140: Dim Y As New A_Win32_Service(X)
141: If Not Y.Save(CMD_Serv) Then Exit For
142: Y = Nothing
143: Next
144: Q5 = Nothing
145: S5 = Nothing
146: Catch ex As Exception
147: Console.WriteLine("*** ОШИБКА *** " & ex.Message)
148: End Try
149:
150: '
151: Console.WriteLine("7.СКАНИРОВАНИЕ ДИСКОВ ******************************************")
152: '
153: Try
154: If PRM.Count > 0 Then
155: 'только заданные
156: For i As Integer = 0 To PRM.Count - 1
157: If Not ScanDir(PRM(i).Replace("\", "").Replace(":", ":\")) Then GoTo end1
158: Next
159: Else
160: 'все диски
161: If Not ScanAll() Then GoTo End1
162: End If
163: end1:
164: CN.Close()
165: Catch ex As Exception
166: Console.WriteLine("*** ОШИБКА *** " & ex.Message)
167: End Try
168: '
169: Console.WriteLine("Завершено. Время работы " & (Now - StartTime).ToString)
170: Console.ReadLine()
171: End If
172: End Sub
173:
174: ''' <summary>
175: ''' Проверка наличия в реестре ConnectionString для этой проги (одновременно служит контролькой, что нужная табла в базе УЖЕ создана)
176: ''' Открытие коннекта к базе и создание экземпляров ADO.NET команд для записи в базу
177: ''' </summary>
178: Function CN_Exists() As Boolean
179: Dim LM, VBN As Microsoft.Win32.RegistryKey
180: Dim CurrentNum As Integer
181: Try
182: LM = My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE", False)
183: VBN = LM.OpenSubKey("VBNET2000", True)
184: Catch ex As Exception
185: Console.WriteLine("Нет доступа к реестру: " & ex.Message)
186: Console.ReadLine()
187: Return False
188: End Try
189: '
190: If VBN.GetValue("WinDump_CN") Is Nothing Then
191: Console.WriteLine("Не задан ConnectionString к базе. Предварительно следует вызвать программу WinDumpSet.exe, которой параметром задать строку подключения к SQL-серверу.")
192: Console.ReadLine()
193: Return False
194: Else
195: '
196: CN.ConnectionString = VBN.GetValue("WinDump_CN").ToString
197: VBN.SetValue("WinDump", CInt(VBN.GetValue("WinDump")) + 1)
198: CurrentNum = CInt(VBN.GetValue("WinDump"))
199: VBN.Close()
200: LM.Close()
201: '
202: Try
203: CN.Open()
204: Catch ex As Exception
205: Console.WriteLine("Не удалось войти в SQL-сервер: " & ex.Message)
206: Console.ReadLine()
207: Return False
208: End Try
209: '
210: Try
211: CMD_File = New CMD_File(CN, CurrentNum)
212: CMD_Dir = New CMD_Dir(CN, CurrentNum)
213: CMD_COM = New CMD_COM(CN, CurrentNum)
214: CMD_DRV = New CMD_DRV(CN, CurrentNum)
215: CMD_GAC = New CMD_GAC(CN, CurrentNum)
216: CMD_Serv = New CMD_Serv(CN, CurrentNum)
217: CMD_Hot = New CMD_Hotfix(CN, CurrentNum)
218: CMD_Soft = New CMD_Soft(CN, CurrentNum)
219: Catch ex As Exception
220: Console.WriteLine("Не удалось инициализировать ADO.NET: " & ex.Message)
221: Console.ReadLine()
222: Return False
223: End Try
224: Return True
225: End If
226: End Function
227:
228: ''' <summary>
229: ''' Сканирование всех жестких дисков
230: ''' </summary>
231: Function ScanAll() As Boolean 'False - если возникла ошибка записи
232: For Each Z As System.IO.DriveInfo In My.Computer.FileSystem.Drives
233: If Z.DriveType.ToString = "Fixed" Then
234: Console.WriteLine(Z.RootDirectory)
235: If Not ScanDir(Z.RootDirectory.ToString) Then Return False
236: End If
237: Next
238: Return True
239: End Function
240:
241: ''' <summary>
242: ''' Рекурсивный разбор заданной директории с записью в базу
243: ''' </summary>
244: Function ScanDir(ByVal StartDir As String) As Boolean 'False - если возникла ошибка записи
245: Dim Start As New System.IO.DirectoryInfo(StartDir)
246: 'В этой директории будут разобраны ВСЕ файлы и ВСЕ поддиректории
247: Try
248: For Each F As System.IO.FileInfo In Start.GetFiles
249: Dim X As New A_FileInfo(F)
250: If Not X.Save(CMD_File) Then Return False
251: X = Nothing
252: Next
253: For Each D As System.IO.DirectoryInfo In Start.GetDirectories
254: Dim X As New A_DirInfo(D)
255: If Not X.Save(CMD_Dir) Then Return False
256: X = Nothing
257: 'собственно рекурсия
258: If Not ScanDir(D.FullName) Then Return False
259: Next
260: Catch ex As Exception
261: 'например System Volume Information не читается - не делаем ничего
262: End Try
263: Return True
264: End Function
265:
266: End Module
Модуль ADO.NET операций утилиты WinDump.
1: ''' <summary>
2: ''' Класс сохранения файла в SQL
3: ''' </summary>
4: Friend Class CMD_File
5: 'команда записи файла и параметры команды
6: Dim CMD_F As SqlClient.SqlCommand = New SqlClient.SqlCommand("INSERT [MyFile]([Dir],[FileName],[CreationTime],[LastWriteTime],[Length],[MD5],[Date],[ToLast],[Num]) " & _
7: "SELECT @Dir, @FileName, @CreationTime, @LastWriteTime, @Length, @Hash, @Date, (select top 1 [i] from [MyFile] where [Dir]=@Dir order by [i] desc),@Num")
8: Dim Dir_F As New SqlClient.SqlParameter("@Dir", SqlDbType.NVarChar)
9: Dim FileName_F As New SqlClient.SqlParameter("@FileName", SqlDbType.NVarChar)
10: Dim CreationTime_F As New SqlClient.SqlParameter("@CreationTime", SqlDbType.DateTime)
11: Dim LastWriteTime_F As New SqlClient.SqlParameter("@LastWriteTime", SqlDbType.DateTime)
12: Dim Length_F As New SqlClient.SqlParameter("@Length", SqlDbType.BigInt)
13: Dim Hash_F As New SqlClient.SqlParameter("@Hash", SqlDbType.Binary)
14: Dim Date_F As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
15: Dim Num_F As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
16:
17: Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
18: CMD_F.Connection = CN
19: CMD_F.Parameters.Add(Dir_F)
20: CMD_F.Parameters.Add(FileName_F)
21: CMD_F.Parameters.Add(CreationTime_F)
22: CMD_F.Parameters.Add(LastWriteTime_F)
23: CMD_F.Parameters.Add(Length_F)
24: CMD_F.Parameters.Add(Hash_F)
25: CMD_F.Parameters.Add(Date_F)
26: CMD_F.Parameters.Add(Num_F)
27: Num_F.Value = Num
28: End Sub
29:
30: ''' <summary>
31: ''' Собственно запись в базу. (True - запись прошла удачно)
32: ''' </summary>
33: 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
34: Dir_F.Value = Dir
35: FileName_F.Value = FileName
36: Length_F.Value = Length
37: CreationTime_F.Value = IIf(CreationTime.Year = 1, New Date(1990, 1, 1), CreationTime)
38: LastWriteTime_F.Value = IIf(LastWriteTime.Year = 1, New Date(1990, 1, 1), LastWriteTime)
39: Hash_F.Value = Hash
40: Date_F.Value = Now
41: For Each PRM As SqlClient.SqlParameter In CMD_F.Parameters
42: If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
43: Next
44: Try
45: CMD_F.ExecuteNonQuery()
46: Return True
47: Catch ex As Exception
48: Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
49: Console.ReadLine()
50: Return False
51: End Try
52: End Function
53: End Class
54:
55: ''' <summary>
56: ''' Класс сохранения директории в SQL
57: ''' </summary>
58: Friend Class CMD_Dir
59: 'команда записи директории и параметры команды
60: Dim CMD_D As SqlClient.SqlCommand = New SqlClient.SqlCommand("INSERT [MyFile]( [Dir],[CreationTime],[LastWriteTime],[Date],[ToLast],[Num]) " & _
61: "SELECT @Dir, @CreationTime, @LastWriteTime,@Date, (select top 1 [i] from [MyFile] where [Dir]=@Dir order by [i] desc),@Num")
62: Dim Dir_D As New SqlClient.SqlParameter("@Dir", SqlDbType.NVarChar)
63: Dim CreationTime_D As New SqlClient.SqlParameter("@CreationTime", SqlDbType.DateTime)
64: Dim LastWriteTime_D As New SqlClient.SqlParameter("@LastWriteTime", SqlDbType.DateTime)
65: Dim Date_D As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
66: Dim Num_D As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
67:
68: Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
69: CMD_D.Connection = CN
70: CMD_D.Parameters.Add(Dir_D)
71: CMD_D.Parameters.Add(CreationTime_D)
72: CMD_D.Parameters.Add(LastWriteTime_D)
73: CMD_D.Parameters.Add(Date_D)
74: CMD_D.Parameters.Add(Num_D)
75: Num_D.Value = Num
76: End Sub
77:
78: ''' <summary>
79: ''' Собственно запись в базу. (True - запись прошла удачно)
80: ''' </summary>
81: Public Function Write(ByVal Dir As String, ByVal CreationTime As DateTime, ByVal LastWriteTime As DateTime) As Boolean
82: Dir_D.Value = Dir
83: CreationTime_D.Value = IIf(CreationTime.Year = 1, New Date(1990, 1, 1), CreationTime)
84: LastWriteTime_D.Value = IIf(LastWriteTime.Year = 1, New Date(1990, 1, 1), LastWriteTime)
85: Date_D.Value = Now
86: For Each PRM As SqlClient.SqlParameter In CMD_D.Parameters
87: If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
88: Next
89: Try
90: CMD_D.ExecuteNonQuery()
91: Return True
92: Catch ex As Exception
93: Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
94: Console.ReadLine()
95: Return False
96: End Try
97: End Function
98:
99: End Class
100:
101: ''' <summary>
102: ''' Класс сохранения сборки из GAC в SQL
103: ''' </summary>
104: Friend Class CMD_GAC
105: 'команда записи сборки GAC и параметры команды
106: Dim CMD_A As SqlClient.SqlCommand = New SqlClient.SqlCommand("INSERT [MyGAC]([Name],[Version],[FullName],[Date],[ToLast],[Num]) " & _
107: "SELECT @Name, @Version, @FullName, @Date, (select top 1 [i] from [MyGAC] where [FullName]=@FullName order by [i] desc),@Num")
108: Dim Name_A As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
109: Dim Version_A As New SqlClient.SqlParameter("@Version", SqlDbType.NVarChar)
110: Dim FullName_A As New SqlClient.SqlParameter("@FullName", SqlDbType.NVarChar)
111: Dim Date_A As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
112: Dim Num_A As New SqlClient.SqlParameter("@Num", SqlDbType.NVarChar)
113:
114: Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
115: CMD_A.Connection = CN
116: CMD_A.Parameters.Add(Name_A)
117: CMD_A.Parameters.Add(Version_A)
118: CMD_A.Parameters.Add(FullName_A)
119: CMD_A.Parameters.Add(Date_A)
120: CMD_A.Parameters.Add(Num_A)
121: Num_A.Value = Num
122: End Sub
123:
124: ''' <summary>
125: ''' Собственно запись сборок GAC в базу. (True - запись прошла удачно)
126: ''' </summary>
127: Public Function Write(ByVal Name As String, ByVal Version As String, ByVal FullName As String) As Boolean
128: Name_A.Value = Name
129: Version_A.Value = Version
130: FullName_A.Value = FullName
131: Date_A.Value = Now
132: For Each PRM As SqlClient.SqlParameter In CMD_A.Parameters
133: If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
134: Next
135: Try
136: CMD_A.ExecuteNonQuery()
137: Return True
138: Catch ex As Exception
139: Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
140: Console.ReadLine()
141: Return False
142: End Try
143: End Function
144: End Class
145:
146: ''' <summary>
147: ''' Класс сохранения службы в SQL
148: ''' </summary>
149: Friend Class CMD_Serv
150:
151: Dim CMD_S As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
152: "INSERT [MyServ] ([AcceptPause] ,[AcceptStop] ,[Caption] ,[CheckPoint] ,[CreationClassName] ,[Description] ,[DesktopInteract]" & _
153: ",[DisplayName] ,[ErrorControl] ,[ExitCode] ,[InstallDate] ,[Name] ,[PathName] ,[ProcessId] ,[ServiceSpecificExitCode]" & _
154: ",[ServiceType] ,[Started] ,[StartMode] ,[StartName] ,[State] ,[Status] ,[SystemCreationClassName] ,[SystemName]" & _
155: ",[TagId] ,[WaitHint] ,[Date] ,[ToLast] ,[Num])" & _
156: "SELECT @AcceptPause, @AcceptStop, @Caption, @CheckPoint, @CreationClassName, @Description, @DesktopInteract, " & _
157: "@DisplayName, @ErrorControl, @ExitCode, @InstallDate, @Name, @PathName, @ProcessId, @ServiceSpecificExitCode, " & _
158: "@ServiceType, @Started, @StartMode, @StartName, @State, @Status, @SystemCreationClassName, @SystemName, " & _
159: "@TagId, @WaitHint, @Date, (select top 1 [i] from [MyServ] where [Name]=@Name order by [i] desc), @Num")
160:
161: Dim AcceptPause_S As New SqlClient.SqlParameter("@AcceptPause", SqlDbType.Bit)
162: Dim AcceptStop_S As New SqlClient.SqlParameter("@AcceptStop", SqlDbType.Bit)
163: Dim Caption_S As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
164: Dim CheckPoint_S As New SqlClient.SqlParameter("@CheckPoint", SqlDbType.Int)
165: Dim CreationClassName_S As New SqlClient.SqlParameter("@CreationClassName", SqlDbType.NVarChar)
166: Dim Description_S As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
167: Dim DesktopInteract_S As New SqlClient.SqlParameter("@DesktopInteract", SqlDbType.Bit)
168: Dim DisplayName_S As New SqlClient.SqlParameter("@DisplayName", SqlDbType.NVarChar)
169: Dim ErrorControl_S As New SqlClient.SqlParameter("@ErrorControl", SqlDbType.NVarChar)
170: Dim ExitCode_S As New SqlClient.SqlParameter("@ExitCode", SqlDbType.Int)
171: Dim InstallDate_S As New SqlClient.SqlParameter("@InstallDate", SqlDbType.DateTime)
172: Dim Name_S As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
173: Dim PathName_S As New SqlClient.SqlParameter("@PathName", SqlDbType.NVarChar)
174: Dim ProcessId_S As New SqlClient.SqlParameter("@ProcessId", SqlDbType.Int)
175: Dim ServiceSpecificExitCode_S As New SqlClient.SqlParameter("@ServiceSpecificExitCode", SqlDbType.Int)
176: Dim ServiceType_S As New SqlClient.SqlParameter("@ServiceType", SqlDbType.NVarChar)
177: Dim Started_S As New SqlClient.SqlParameter("@Started", SqlDbType.Bit)
178: Dim StartMode_S As New SqlClient.SqlParameter("@StartMode", SqlDbType.NVarChar)
179: Dim StartName_S As New SqlClient.SqlParameter("@StartName", SqlDbType.NVarChar)
180: Dim State_S As New SqlClient.SqlParameter("@State", SqlDbType.NVarChar)
181: Dim Status_S As New SqlClient.SqlParameter("@Status", SqlDbType.NVarChar)
182: Dim SystemCreationClassName_S As New SqlClient.SqlParameter("@SystemCreationClassName", SqlDbType.NVarChar)
183: Dim SystemName_S As New SqlClient.SqlParameter("@SystemName", SqlDbType.NVarChar)
184: Dim TagId_S As New SqlClient.SqlParameter("@TagId", SqlDbType.Int)
185: Dim WaitHint_S As New SqlClient.SqlParameter("@WaitHint", SqlDbType.Int)
186: Dim Date_S As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
187: Dim Num_S As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
188:
189: Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
190: CMD_S.Connection = CN
191: CMD_S.Parameters.Add(AcceptPause_S)
192: CMD_S.Parameters.Add(AcceptStop_S)
193: CMD_S.Parameters.Add(Caption_S)
194: CMD_S.Parameters.Add(CheckPoint_S)
195: CMD_S.Parameters.Add(CreationClassName_S)
196: CMD_S.Parameters.Add(Description_S)
197: CMD_S.Parameters.Add(DesktopInteract_S)
198: CMD_S.Parameters.Add(DisplayName_S)
199: CMD_S.Parameters.Add(ErrorControl_S)
200: CMD_S.Parameters.Add(ExitCode_S)
201: CMD_S.Parameters.Add(InstallDate_S)
202: CMD_S.Parameters.Add(Name_S)
203: CMD_S.Parameters.Add(PathName_S)
204: CMD_S.Parameters.Add(ProcessId_S)
205: CMD_S.Parameters.Add(ServiceSpecificExitCode_S)
206: CMD_S.Parameters.Add(ServiceType_S)
207: CMD_S.Parameters.Add(Started_S)
208: CMD_S.Parameters.Add(StartMode_S)
209: CMD_S.Parameters.Add(StartName_S)
210: CMD_S.Parameters.Add(State_S)
211: CMD_S.Parameters.Add(Status_S)
212: CMD_S.Parameters.Add(SystemCreationClassName_S)
213: CMD_S.Parameters.Add(SystemName_S)
214: CMD_S.Parameters.Add(TagId_S)
215: CMD_S.Parameters.Add(WaitHint_S)
216: CMD_S.Parameters.Add(Date_S)
217: CMD_S.Parameters.Add(Num_S)
218: Num_S.Value = Num
219: End Sub
220:
221: ''' <summary>
222: ''' Собственно запись служб в базу. (True - запись прошла удачно)
223: ''' </summary>
224: Public Function Write(ByVal AcceptPause As Boolean, ByVal AcceptStop As Boolean, ByVal Caption As String, _
225: ByVal CheckPoint As Integer, ByVal CreationClassName As String, ByVal Description As String, ByVal DesktopInteract As Boolean, _
226: ByVal DisplayName As String, ByVal ErrorControl As String, ByVal ExitCode As Integer, ByVal InstallDate As DateTime, _
227: ByVal Name As String, ByVal PathName As String, ByVal ProcessId As Integer, ByVal ServiceSpecificExitCode As Integer, _
228: ByVal ServiceType As String, ByVal Started As Boolean, ByVal StartMode As String, ByVal StartName As String, _
229: ByVal State As String, ByVal Status As String, ByVal SystemCreationClassName As String, ByVal SystemName As String, _
230: ByVal TagId As Integer, ByVal WaitHint As Integer) As Boolean
231: AcceptPause_S.Value = AcceptPause
232: AcceptStop_S.Value = AcceptStop
233: Caption_S.Value = Caption
234: CheckPoint_S.Value = CheckPoint
235: CreationClassName_S.Value = CreationClassName
236: Description_S.Value = Description
237: DesktopInteract_S.Value = DesktopInteract
238: DisplayName_S.Value = DisplayName
239: ExitCode_S.Value = ExitCode
240: InstallDate_S.Value = IIf(InstallDate.Year = 1, New Date(1990, 1, 1), InstallDate)
241: Name_S.Value = Name
242: PathName_S.Value = PathName
243: ProcessId_S.Value = ProcessId
244: ServiceSpecificExitCode_S.Value = ServiceSpecificExitCode
245: ServiceType_S.Value = ServiceType
246: Started_S.Value = Started
247: StartMode_S.Value = StartMode
248: StartName_S.Value = StartName
249: State_S.Value = State
250: Status_S.Value = Status
251: SystemCreationClassName_S.Value = SystemCreationClassName
252: SystemName_S.Value = SystemName
253: WaitHint_S.Value = WaitHint
254: TagId_S.Value = TagId
255: Date_S.Value = Now
256: For Each PRM As SqlClient.SqlParameter In CMD_S.Parameters
257: If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
258: Next
259: Try
260: CMD_S.ExecuteNonQuery()
261: Return True
262: Catch ex As Exception
263: Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
264: Console.ReadLine()
265: Return False
266: End Try
267: End Function
268:
269: End Class
270:
271: ''' <summary>
272: ''' Класс сохранения драйвера в SQL
273: ''' </summary>
274: ''' <remarks></remarks>
275: Friend Class CMD_DRV
276:
277: Dim CMD_R As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
278: "INSERT [MyDRV] ([AcceptPause] ,[AcceptStop] ,[Caption] ,[CreationClassName] ,[Description] ,[DesktopInteract]" & _
279: ",[DisplayName], [ErrorControl] ,[ExitCode] ,[InstallDate] ,[Name] ,[PathName] ,[ServiceSpecificExitCode] ,[ServiceType]" & _
280: ",[Started] ,[StartMode] ,[StartName] ,[State] ,[Status] ,[SystemCreationClassName] ,[SystemName]" & _
281: ",[TagId] ,[Date] ,[ToLast] ,[Num])" & _
282: "SELECT @AcceptPause, @AcceptStop, @Caption, @CreationClassName, @Description, @DesktopInteract, @DisplayName, " & _
283: "@ErrorControl, @ExitCode, @InstallDate, @Name, @PathName, @ServiceSpecificExitCode, @ServiceType, @Started, @StartMode, " & _
284: "@StartName, @State, @Status, @SystemCreationClassName, @SystemName, @TagId, @Date, (select top 1 [i] from [MyDRV] where [Name]=@Name order by [i] desc), @Num")
285:
286: Dim AcceptPause_R As New SqlClient.SqlParameter("@AcceptPause", SqlDbType.Bit)
287: Dim AcceptStop_R As New SqlClient.SqlParameter("@AcceptStop", SqlDbType.Bit)
288: Dim Caption_R As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
289: Dim CreationClassName_R As New SqlClient.SqlParameter("@CreationClassName", SqlDbType.NVarChar)
290: Dim Description_R As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
291: Dim DesktopInteract_R As New SqlClient.SqlParameter("@DesktopInteract", SqlDbType.Bit)
292: Dim DisplayName_R As New SqlClient.SqlParameter("@DisplayName", SqlDbType.NVarChar)
293: Dim ErrorControl_R As New SqlClient.SqlParameter("@ErrorControl", SqlDbType.NVarChar)
294: Dim ExitCode_R As New SqlClient.SqlParameter("@ExitCode", SqlDbType.Int)
295: Dim InstallDate_R As New SqlClient.SqlParameter("@InstallDate", SqlDbType.DateTime)
296: Dim Name_R As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
297: Dim PathName_R As New SqlClient.SqlParameter("@PathName", SqlDbType.NVarChar)
298: Dim ServiceSpecificExitCode_R As New SqlClient.SqlParameter("@ServiceSpecificExitCode", SqlDbType.Int)
299: Dim ServiceType_R As New SqlClient.SqlParameter("@ServiceType", SqlDbType.NVarChar)
300: Dim Started_R As New SqlClient.SqlParameter("@Started", SqlDbType.Bit)
301: Dim StartMode_R As New SqlClient.SqlParameter("@StartMode", SqlDbType.NVarChar)
302: Dim StartName_R As New SqlClient.SqlParameter("@StartName", SqlDbType.NVarChar)
303: Dim State_R As New SqlClient.SqlParameter("@State", SqlDbType.NVarChar)
304: Dim Status_R As New SqlClient.SqlParameter("@Status", SqlDbType.NVarChar)
305: Dim SystemCreationClassName_R As New SqlClient.SqlParameter("@SystemCreationClassName", SqlDbType.NVarChar)
306: Dim SystemName_R As New SqlClient.SqlParameter("@SystemName", SqlDbType.NVarChar)
307: Dim TagId_R As New SqlClient.SqlParameter("@TagId", SqlDbType.Int)
308: Dim Date_R As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
309: Dim Num_R As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
310:
311:
312: Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
313: CMD_R.Connection = CN
314: CMD_R.Parameters.Add(AcceptPause_R)
315: CMD_R.Parameters.Add(AcceptStop_R)
316: CMD_R.Parameters.Add(Caption_R)
317: CMD_R.Parameters.Add(CreationClassName_R)
318: CMD_R.Parameters.Add(Description_R)
319: CMD_R.Parameters.Add(DesktopInteract_R)
320: CMD_R.Parameters.Add(DisplayName_R)
321: CMD_R.Parameters.Add(ErrorControl_R)
322: CMD_R.Parameters.Add(ExitCode_R)
323: CMD_R.Parameters.Add(InstallDate_R)
324: CMD_R.Parameters.Add(Name_R)
325: CMD_R.Parameters.Add(PathName_R)
326: CMD_R.Parameters.Add(ServiceSpecificExitCode_R)
327: CMD_R.Parameters.Add(ServiceType_R)
328: CMD_R.Parameters.Add(Started_R)
329: CMD_R.Parameters.Add(StartMode_R)
330: CMD_R.Parameters.Add(StartName_R)
331: CMD_R.Parameters.Add(State_R)
332: CMD_R.Parameters.Add(Status_R)
333: CMD_R.Parameters.Add(SystemCreationClassName_R)
334: CMD_R.Parameters.Add(SystemName_R)
335: CMD_R.Parameters.Add(TagId_R)
336: CMD_R.Parameters.Add(Date_R)
337: CMD_R.Parameters.Add(Num_R)
338: Num_R.Value = Num
339: End Sub
340:
341: ''' <summary>
342: ''' Собственно запись драйверов в базу. (True - запись прошла удачно)
343: ''' </summary>
344: Public Function Write(ByVal AcceptPause As Boolean, ByVal AcceptStop As Boolean, ByVal Caption As String, ByVal CreationClassName As String, _
345: ByVal Description As String, ByVal DesktopInteract As Boolean, ByVal DisplayName As String, ByVal ErrorControl As String, ByVal ExitCode As Integer, _
346: ByVal InstallDate As DateTime, ByVal Name As String, ByVal PathName As String, ByVal ServiceSpecificExitCode As Integer, _
347: ByVal ServiceType As String, ByVal Started As Boolean, ByVal StartMode As String, ByVal StartName As String, ByVal State As String, _
348: ByVal Status As String, ByVal SystemCreationClassName As String, ByVal SystemName As String, ByVal TagId As Integer) As Boolean
349: AcceptPause_R.Value = AcceptPause
350: AcceptStop_R.Value = AcceptStop
351: Caption_R.Value = Caption
352: CreationClassName_R.Value = CreationClassName
353: Description_R.Value = Description
354: DesktopInteract_R.Value = DesktopInteract
355: DisplayName_R.Value = DisplayName
356: ErrorControl_R.value = ErrorControl
357: ExitCode_R.Value = ExitCode
358: InstallDate_R.Value = IIf(InstallDate.Year = 1, New Date(1990, 1, 1), InstallDate)
359: Name_R.Value = Name
360: PathName_R.Value = PathName
361: ServiceSpecificExitCode_R.Value = ServiceSpecificExitCode
362: ServiceType_R.Value = ServiceType
363: Started_R.Value = Started
364: StartMode_R.Value = StartMode
365: StartName_R.Value = StartName
366: State_R.Value = State
367: Status_R.Value = Status
368: SystemCreationClassName_R.Value = SystemCreationClassName
369: SystemName_R.Value = SystemName
370: TagId_R.Value = TagId
371: Date_R.Value = Now
372: For Each PRM As SqlClient.SqlParameter In CMD_R.Parameters
373: If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
374: Next
375: Try
376: CMD_R.ExecuteNonQuery()
377: Return True
378: Catch ex As Exception
379: Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
380: Console.ReadLine()
381: Return False
382: End Try
383: End Function
384:
385: End Class
386:
387: ''' <summary>
388: ''' Класс сохранения хотфикса в SQL
389: ''' </summary>
390: Friend Class CMD_Hotfix
391:
392: Dim CMD_H As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
393: "INSERT [MyHotfix]([Caption] ,[CSName] ,[Description] ,[FixComments] ,[HotFixID] ,[InstallDate] ,[InstalledBy] ,[InstalledOn]" & _
394: ",[Name] ,[ServicePackInEffect] ,[Status] ,[Date] ,[ToLast] ,[Num])" & _
395: "SELECT @Caption, @CSName, @Description, @FixComments, @HotFixID, @InstallDate, @InstalledBy, @InstalledOn, @Name, " & _
396: "@ServicePackInEffect, @Status, @Date, 0, @Num")
397:
398: Dim Caption_H As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
399: Dim CSName_H As New SqlClient.SqlParameter("@CSName", SqlDbType.NVarChar)
400: Dim Description_H As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
401: Dim FixComments_H As New SqlClient.SqlParameter("@FixComments", SqlDbType.NVarChar)
402: Dim HotFixID_H As New SqlClient.SqlParameter("@HotFixID", SqlDbType.NVarChar)
403: Dim InstallDate_H As New SqlClient.SqlParameter("@InstallDate", SqlDbType.DateTime)
404: Dim InstalledBy_H As New SqlClient.SqlParameter("@InstalledBy", SqlDbType.NVarChar)
405: Dim InstalledOn_H As New SqlClient.SqlParameter("@InstalledOn", SqlDbType.NVarChar)
406: Dim Name_H As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
407: Dim ServicePackInEffect_H As New SqlClient.SqlParameter("@ServicePackInEffect", SqlDbType.NVarChar)
408: Dim Status_H As New SqlClient.SqlParameter("@Status", SqlDbType.NVarChar)
409: Dim Date_H As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
410: Dim Num_H As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
411:
412: Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
413: CMD_H.Connection = CN
414: CMD_H.Parameters.Add(Caption_H)
415: CMD_H.Parameters.Add(CSName_H)
416: CMD_H.Parameters.Add(Description_H)
417: CMD_H.Parameters.Add(FixComments_H)
418: CMD_H.Parameters.Add(HotFixID_H)
419: CMD_H.Parameters.Add(InstallDate_H)
420: CMD_H.Parameters.Add(InstalledBy_H)
421: CMD_H.Parameters.Add(InstalledOn_H)
422: CMD_H.Parameters.Add(Name_H)
423: CMD_H.Parameters.Add(ServicePackInEffect_H)
424: CMD_H.Parameters.Add(Status_H)
425: CMD_H.Parameters.Add(Date_H)
426: CMD_H.Parameters.Add(Num_H)
427: Num_H.Value = Num
428: End Sub
429:
430: ''' <summary>
431: ''' Собственно запись хотфиксов в базу. (True - запись прошла удачно)
432: ''' </summary>
433: Public Function Write(ByVal Caption As String, ByVal CSName As String, ByVal Description As String, ByVal FixComments As String, _
434: ByVal HotFixID As String, ByVal InstallDate As DateTime, ByVal InstalledBy As String, ByVal InstalledOn As String, _
435: ByVal Name As String, ByVal ServicePackInEffect As String, ByVal Status As String) As Boolean
436: Caption_H.Value = Caption
437: CSName_H.Value = CSName
438: Description_H.Value = Description
439: FixComments_H.Value = FixComments
440: HotFixID_H.Value = HotFixID
441: InstallDate_H.Value = IIf(InstallDate.Year = 1, New Date(1990, 1, 1), InstallDate)
442: InstalledBy_H.Value = InstalledBy
443: InstalledOn_H.Value = InstalledOn
444: Name_H.Value = Name
445: ServicePackInEffect_H.Value = ServicePackInEffect
446: Status_H.Value = Status
447: Date_H.Value = Now
448: For Each PRM As SqlClient.SqlParameter In CMD_H.Parameters
449: If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
450: Next
451: Try
452: CMD_H.ExecuteNonQuery()
453: Return True
454: Catch ex As Exception
455: Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
456: Console.ReadLine()
457: Return False
458: End Try
459: End Function
460:
461: End Class
462:
463: ''' <summary>
464: ''' Класс сохранения COM-обьекта в SQL
465: ''' </summary>
466: Friend Class CMD_COM
467:
468: Dim CMD_C As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
469: "INSERT INTO [MyCOM] ([AppID], [AutoConvertToClsid] ,[AutoTreatAsClsid] ,[Caption] ,[ComponentId] ,[Control] ,[DefaultIcon]" & _
470: ",[Description] ,[InprocHandler] ,[InprocHandler32] ,[InprocServer] ,[InprocServer32] ,[Insertable] ,[JavaClass]" & _
471: ",[LocalServer] ,[LocalServer32] ,[LongDisplayName] ,[ProgId] ,[SettingID] ,[ShortDisplayName] ,[ThreadingModel]" & _
472: ",[ToolBoxBitmap32] ,[TreatAsClsid] ,[TypeLibraryId] ,[Version] ,[VersionIndependentProgId] ,[Date]" & _
473: ",[ToLast] ,[Num])" & _
474: "SELECT @AppID, @AutoConvertToClsid, @AutoTreatAsClsid ,@Caption ,@ComponentId ,@Control, @DefaultIcon, @Description" & _
475: ",@InprocHandler, @InprocHandler32, @InprocServer, @InprocServer32, @Insertable, @JavaClass, @LocalServer" & _
476: ",@LocalServer32, @LongDisplayName, @ProgId, @SettingID, @ShortDisplayName, @ThreadingModel, @ToolBoxBitmap32 " & _
477: ",@TreatAsClsid, @TypeLibraryId, @Version, @VersionIndependentProgId, @Date, (select top 1 [i] from [MyCOM] where [ComponentId]=@ComponentId order by [i] desc), @Num")
478:
479: Dim AppID_C As New SqlClient.SqlParameter("@AppID", SqlDbType.NVarChar)
480: Dim AutoConvertToClsid_C As New SqlClient.SqlParameter("@AutoConvertToClsid", SqlDbType.NVarChar)
481: Dim AutoTreatAsClsid_C As New SqlClient.SqlParameter("@AutoTreatAsClsid", SqlDbType.NVarChar)
482: Dim Caption_C As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
483: Dim ComponentId_C As New SqlClient.SqlParameter("@ComponentId", SqlDbType.NVarChar)
484: Dim Control_C As New SqlClient.SqlParameter("Control", SqlDbType.bit)
485: Dim DefaultIcon_C As New SqlClient.SqlParameter("@DefaultIcon", SqlDbType.NVarChar)
486: Dim Description_C As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
487: Dim InprocHandler_C As New SqlClient.SqlParameter("@InprocHandler", SqlDbType.NVarChar)
488: Dim InprocHandler32_C As New SqlClient.SqlParameter("@InprocHandler32", SqlDbType.NVarChar)
489: Dim InprocServer_C As New SqlClient.SqlParameter("@InprocServer", SqlDbType.NVarChar)
490: Dim InprocServer32_C As New SqlClient.SqlParameter("@InprocServer32", SqlDbType.NVarChar)
491: Dim Insertable_C As New SqlClient.SqlParameter("Insertable", Data.SqlDbType.Bit)
492: Dim JavaClass_C As New SqlClient.SqlParameter("JavaClass", SqlDbType.NVarChar)
493: Dim LocalServer_C As New SqlClient.SqlParameter("@LocalServer", SqlDbType.NVarChar)
494: Dim LocalServer32_C As New SqlClient.SqlParameter("@LocalServer32", SqlDbType.NVarChar)
495: Dim LongDisplayName_C As New SqlClient.SqlParameter("@LongDisplayName", SqlDbType.NVarChar)
496: Dim ProgId_C As New SqlClient.SqlParameter("@ProgId", SqlDbType.NVarChar)
497: Dim SettingID_C As New SqlClient.SqlParameter("@SettingID", SqlDbType.NVarChar)
498: Dim ShortDisplayName_C As New SqlClient.SqlParameter("@ShortDisplayName", SqlDbType.NVarChar)
499: Dim ThreadingModel_C As New SqlClient.SqlParameter("@ThreadingModel", SqlDbType.NVarChar)
500: Dim ToolBoxBitmap32_C As New SqlClient.SqlParameter("@ToolBoxBitmap32", SqlDbType.NVarChar)
501: Dim TreatAsClsid_C As New SqlClient.SqlParameter("@TreatAsClsid", SqlDbType.NVarChar)
502: Dim TypeLibraryId_C As New SqlClient.SqlParameter("@TypeLibraryId", SqlDbType.NVarChar)
503: Dim Version_C As New SqlClient.SqlParameter("@Version", SqlDbType.NVarChar)
504: Dim VersionIndependentProgId_C As New SqlClient.SqlParameter("@VersionIndependentProgId", SqlDbType.NVarChar)
505: Dim Date_C As New SqlClient.SqlParameter("Date", SqlDbType.DateTime)
506: Dim Num_C As New SqlClient.SqlParameter("Num", SqlDbType.Int)
507:
508: Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
509: CMD_C.Connection = CN
510: CMD_C.Parameters.Add(AppID_C)
511: CMD_C.Parameters.Add(AutoConvertToClsid_C)
512: CMD_C.Parameters.Add(AutoTreatAsClsid_C)
513: CMD_C.Parameters.Add(Caption_C)
514: CMD_C.Parameters.Add(ComponentId_C)
515: CMD_C.Parameters.Add(Control_C)
516: CMD_C.Parameters.Add(DefaultIcon_C)
517: CMD_C.Parameters.Add(Description_C)
518: CMD_C.Parameters.Add(InprocHandler_C)
519: CMD_C.Parameters.Add(InprocHandler32_C)
520: CMD_C.Parameters.Add(InprocServer_C)
521: CMD_C.Parameters.Add(InprocServer32_C)
522: CMD_C.Parameters.Add(Insertable_C)
523: CMD_C.Parameters.Add(JavaClass_C)
524: CMD_C.Parameters.Add(LocalServer_C)
525: CMD_C.Parameters.Add(LocalServer32_C)
526: CMD_C.Parameters.Add(LongDisplayName_C)
527: CMD_C.Parameters.Add(ProgId_C)
528: CMD_C.Parameters.Add(SettingID_C)
529: CMD_C.Parameters.Add(ShortDisplayName_C)
530: CMD_C.Parameters.Add(ThreadingModel_C)
531: CMD_C.Parameters.Add(ToolBoxBitmap32_C)
532: CMD_C.Parameters.Add(TreatAsClsid_C)
533: CMD_C.Parameters.Add(TypeLibraryId_C)
534: CMD_C.Parameters.Add(Version_C)
535: CMD_C.Parameters.Add(VersionIndependentProgId_C)
536: CMD_C.Parameters.Add(Date_C)
537: CMD_C.Parameters.Add(Num_C)
538: Num_C.Value = Num
539: End Sub
540:
541: ''' <summary>
542: ''' Собственно запись COM-обьектов в базу. (True - запись прошла удачно)
543: ''' </summary>
544: Public Function Write(ByVal AppID As String, ByVal AutoConvertToClsid As String, ByVal AutoTreatAsClsid As String, ByVal Caption As String, _
545: ByVal ComponentId As String, ByVal Control As Boolean, ByVal DefaultIcon As String, ByVal Description As String, ByVal InprocHandler As String, _
546: ByVal InprocHandler32 As String, ByVal InprocServer As String, ByVal InprocServer32 As String, ByVal Insertable As Boolean, _
547: ByVal JavaClass As String, ByVal LocalServer As String, ByVal LocalServer32 As String, ByVal LongDisplayName As String, _
548: ByVal ProgId As String, ByVal SettingID As String, ByVal ShortDisplayName As String, ByVal ThreadingModel As String, ByVal ToolBoxBitmap32 As String, _
549: ByVal TreatAsClsid As String, ByVal TypeLibraryId As String, ByVal Version As String, ByVal VersionIndependentProgId As String) As Boolean
550: AppID_C.Value = AppID
551: AutoConvertToClsid_C.Value = AutoConvertToClsid
552: AutoTreatAsClsid_C.Value = AutoTreatAsClsid
553: Caption_C.Value = Caption
554: ComponentId_C.Value = ComponentId
555: Control_C.Value = Control
556: DefaultIcon_C.Value = DefaultIcon
557: Description_C.Value = Description
558: InprocHandler_C.Value = InprocHandler
559: InprocHandler32_C.Value = InprocHandler32
560: InprocServer_C.Value = InprocServer
561: InprocServer32_C.Value = InprocServer32
562: Insertable_C.Value = Insertable
563: JavaClass_C.Value = JavaClass
564: LocalServer_C.Value = LocalServer
565: LocalServer32_C.Value = LocalServer32
566: LongDisplayName_C.Value = LongDisplayName
567: ProgId_C.Value = ProgId
568: SettingID_C.Value = SettingID
569: ShortDisplayName_C.Value = ShortDisplayName
570: ThreadingModel_C.Value = ThreadingModel
571: ToolBoxBitmap32_C.Value = ToolBoxBitmap32
572: TreatAsClsid_C.Value = TreatAsClsid
573: TypeLibraryId_C.Value = TypeLibraryId
574: Version_C.Value = Version
575: VersionIndependentProgId_C.Value = VersionIndependentProgId
576: Date_C.Value = Now
577: For Each PRM As SqlClient.SqlParameter In CMD_C.Parameters
578: If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
579: Next
580: Try
581: CMD_C.ExecuteNonQuery()
582: Return True
583: Catch ex As Exception
584: Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
585: Console.ReadLine()
586: Return False
587: End Try
588: End Function
589:
590: End Class
591:
592: ''' <summary>
593: ''' Класс сохранения инсталлированных пакетов программ в SQL
594: ''' </summary>
595: Friend Class CMD_Soft
596:
597: Dim CMD_P As SqlClient.SqlCommand = New SqlClient.SqlCommand( _
598: "INSERT [MySoft] ([Accesses] ,[Attributes] ,[Caption] ,[Description] ,[IdentifyingNumber] ,[InstallDate] ,[InstallState]" & _
599: ",[LastUse] ,[Name] ,[ProductName] ,[Status] ,[Vendor] ,[Version] ,[Date] ,[ToLast] ,[Num])" & _
600: "SELECT @Accesses, @Attributes, @Caption, @Description, @IdentifyingNumber, @InstallDate, @InstallState," & _
601: "@LastUse, @Name, @ProductName, @Status, @Vendor, @Version, @Date, (select top 1 [i] from [MySoft] where [IdentifyingNumber]=@IdentifyingNumber order by [i] desc), @Num")
602:
603: Dim Accesses_P As New SqlClient.SqlParameter("@Accesses", SqlDbType.SmallInt)
604: Dim Attributes_P As New SqlClient.SqlParameter("@Attributes", SqlDbType.SmallInt)
605: Dim Caption_P As New SqlClient.SqlParameter("@Caption", SqlDbType.NVarChar)
606: Dim Description_P As New SqlClient.SqlParameter("@Description", SqlDbType.NVarChar)
607: Dim IdentifyingNumber_P As New SqlClient.SqlParameter("@IdentifyingNumber", SqlDbType.NVarChar)
608: Dim InstallDate_P As New SqlClient.SqlParameter("@InstallDate", SqlDbType.DateTime)
609: Dim InstallState_P As New SqlClient.SqlParameter("@InstallState", SqlDbType.SmallInt)
610: Dim LastUse_P As New SqlClient.SqlParameter("@LastUse", SqlDbType.NVarChar)
611: Dim Name_P As New SqlClient.SqlParameter("@Name", SqlDbType.NVarChar)
612: Dim ProductName_P As New SqlClient.SqlParameter("@ProductName", SqlDbType.NVarChar)
613: Dim Status_P As New SqlClient.SqlParameter("@Status", SqlDbType.NVarChar)
614: Dim Vendor_P As New SqlClient.SqlParameter("@Vendor", SqlDbType.NVarChar)
615: Dim Version_P As New SqlClient.SqlParameter("@Version", SqlDbType.NVarChar)
616: Dim Date_P As New SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
617: Dim Num_P As New SqlClient.SqlParameter("@Num", SqlDbType.Int)
618:
619: Public Sub New(ByVal CN As SqlClient.SqlConnection, ByVal Num As Integer)
620: CMD_P.Connection = CN
621: CMD_P.Parameters.Add(Accesses_P)
622: CMD_P.Parameters.Add(Attributes_P)
623: CMD_P.Parameters.Add(Caption_P)
624: CMD_P.Parameters.Add(Description_P)
625: CMD_P.Parameters.Add(IdentifyingNumber_P)
626: CMD_P.Parameters.Add(InstallDate_P)
627: CMD_P.Parameters.Add(InstallState_P)
628: CMD_P.Parameters.Add(LastUse_P)
629: CMD_P.Parameters.Add(Name_P)
630: CMD_P.Parameters.Add(ProductName_P)
631: CMD_P.Parameters.Add(Status_P)
632: CMD_P.Parameters.Add(Vendor_P)
633: CMD_P.Parameters.Add(Version_P)
634: CMD_P.Parameters.Add(Date_P)
635: CMD_P.Parameters.Add(Num_P)
636: Num_P.Value = Num
637: End Sub
638:
639: ''' <summary>
640: ''' Собственно запись программых пакетов в базу. (True - запись прошла удачно)
641: ''' </summary>
642: Public Function Write(ByVal Accesses As UInt16, ByVal Attributes As UInt16, ByVal Caption As String, ByVal Description As String, _
643: ByVal IdentifyingNumber As String, ByVal InstallDate As DateTime, ByVal InstallState As UInt16, ByVal LastUse As String, _
644: ByVal Name As String, ByVal ProductName As String, ByVal Status As String, ByVal Vendor As String, ByVal Version As String) As Boolean
645: Accesses_P.Value = Accesses
646: Attributes_P.Value = Attributes
647: Caption_P.Value = Caption
648: Description_P.Value = Description
649: IdentifyingNumber_P.Value = IdentifyingNumber
650: InstallDate_P.Value = IIf(InstallDate.Year = 1, New Date(1990, 1, 1), InstallDate)
651: InstallState_P.Value = InstallState
652: LastUse_P.Value = LastUse
653: Name_P.Value = Name
654: ProductName_P.Value = ProductName
655: Status_P.Value = Status
656: Vendor_P.Value = Vendor
657: Version_P.Value = Version
658: Date_P.Value = Now
659: For Each PRM As SqlClient.SqlParameter In CMD_P.Parameters
660: If PRM.Value Is Nothing And PRM.DbType = DbType.String Then PRM.Value = " "
661: Next
662: Try
663: CMD_P.ExecuteNonQuery()
664: Return True
665: Catch ex As Exception
666: Console.WriteLine("Не удалось выполнить запись. " & ex.Message)
667: Console.ReadLine()
668: Return False
669: End Try
670: End Function
671:
672: End Class
673:
674: 'Пример кода, формируемого ADO.NET:
675: 'exec sp_executesql N'INSERT INTO [MyCOM] ([AppID], [AutoConvertToClsid] ,[AutoTreatAsClsid] ,[Caption] ,[ComponentId] ,[Control]
676: ',[DefaultIcon],[Description] ,[InprocHandler] ,[InprocHandler32] ,[InprocServer] ,[InprocServer32] ,[Insertable]
677: ',[JavaClass],[LocalServer] ,[LocalServer32] ,[LongDisplayName] ,[ProgId] ,[SettingID] ,[ShortDisplayName]
678: ',[ThreadingModel],[ToolBoxBitmap32] ,[TreatAsClsid] ,[TypeLibraryId] ,[Version] ,[VersionIndependentProgId] ,[Date],[ToLast]
679: ',[Num])VALUES (@AppID, @AutoConvertToClsid, ,@AutoTreatAsClsid ,@Caption ,@ComponentId ,@Control, @DefaultIcon,
680: '@Description,,@InprocHandler, @InprocHandler32, @InprocServer, @InprocServer32, @Insertable, @JavaClass, @LocalServer,,@LocalServer32,
681: '@LongDisplayName, @ProgId, @SettingID, @ShortDisplayName, @ThreadingModel, @ToolBoxBitmap32, ,@TreatAsClsid, @TypeLibraryId, @Version,
682: '@VersionIndependentProgId, @Date, @ToLast, @Num)',N'@AppID nvarchar(38),@AutoConvertToClsid nvarchar(1),@AutoTreatAsClsid
683: 'nvarchar(1),@Caption nvarchar(16),@ComponentId nvarchar(36),@Control bit,@DefaultIcon nvarchar(1),@Description
684: 'nvarchar(16),@InprocHandler nvarchar(1),@InprocHandler32 nvarchar(1),@InprocServer nvarchar(1),@InprocServer32 nvarchar(1),@Insertable
685: 'bit,@JavaClass As Boolean nvarchar(5),@LocalServer nvarchar(1),@LocalServer32 nvarchar(49),@LongDisplayName nvarchar(1),@ProgId
686: 'nvarchar(30),@SettingID nvarchar(1),@ShortDisplayName nvarchar(1),@ThreadingModel nvarchar(1),@ToolBoxBitmap32 nvarchar(1),@TreatAsClsid
687: 'nvarchar(1),@TypeLibraryId nvarchar(1),@Version nvarchar(1),@VersionIndependentProgId nvarchar(1),@Date datetime,@ToLast int,@Num int',
688: '@AppID=N'{CB74D869-2D98-447A-A9D8-DBFB0DFDF4E7}',
689: '@AutoConvertToClsid=N' ',
690: '@AutoTreatAsClsid=N' ',
691: '@Caption=N'Downloader Class',
692: '@ComponentId=N'F3C2CEA1-A38A-468B-A3AC-8DC708B79D59',
693: '@Control=0,@DefaultIcon=N' ',
694: '@Description=N'Downloader Class',
695: '@InprocHandler=N' ',
696: '@InprocHandler32=N' ',
697: '@InprocServer=N' ',
698: '@InprocServer32=N' ',
699: '@Insertable=0,
700: '@JavaClass as boolean ='False',
701: '@LocalServer=N' ',
702: '@LocalServer32=N'C:\PROGRA~1\COMMON~1\INSTAL~1\UPDATE~1\BOISDM.exe',
703: '@LongDisplayName=N' ',
704: '@ProgId=N'ISDownloadManager.Downloader.1',
705: '@SettingID=N' ',
706: '@ShortDisplayName=N' ',
707: '@ThreadingModel=N' ',
708: '@ToolBoxBitmap32=N' ',
709: '@TreatAsClsid=N' ',
710: '@TypeLibraryId=N' ',
711: '@Version=N' ',
712: '@VersionIndependentProgId=N' ',
713: '@Date=''2007-02-05 23:42:39:063'',
714: '@ToLast=0,
715: '@Num=74
Модуль описаний WMI утилиты WinDump.
1: ''' <summary>
2: ''' Структура WMI-класса Win32_SoftwareFeature
3: ''' </summary>
4: Friend Class A_Win32_SoftwareFeature ' : CIM_SoftwareFeature
5:
6: Public Sub New(ByVal X As System.Management.ManagementObject)
7: Accesses = X.GetPropertyValue("Accesses")
8: Attributes = X.GetPropertyValue("Attributes")
9: Caption = X.GetPropertyValue("Caption")
10: Description = X.GetPropertyValue("Description")
11: IdentifyingNumber = X.GetPropertyValue("IdentifyingNumber")
12: InstallDate = X.GetPropertyValue("InstallDate")
13: InstallState = X.GetPropertyValue("InstallState")
14: LastUse = X.GetPropertyValue("LastUse")
15: Name = X.GetPropertyValue("Name")
16: ProductName = X.GetPropertyValue("ProductName")
17: Status = X.GetPropertyValue("Status")
18: Vendor = X.GetPropertyValue("Vendor")
19: Version = X.GetPropertyValue("Version")
20: End Sub
21:
22: Dim Accesses As UInt16
23: Dim Attributes As UInt16
24: Dim Caption As String
25: Dim Description As String
26: Dim IdentifyingNumber As String
27: Dim InstallDate As DateTime
28: Dim InstallState As UInt16
29: Dim LastUse As String 'тут непонятный баг
30: Dim Name As String
31: Dim ProductName As String
32: Dim Status As String
33: Dim Vendor As String
34: Dim Version As String
35:
36: ''' <summary>
37: ''' Сохранение класса Win32_SoftwareFeature в базу (True - записалось удачно)
38: ''' </summary>
39: Public Function Save(ByVal CMD As CMD_Soft) As Boolean
40: Return CMD.Write(Accesses, Attributes, Caption, Description, IdentifyingNumber, InstallDate, InstallState, _
41: LastUse, Name, ProductName, Status, Vendor, Version)
42: End Function
43:
44: End Class
45:
46: ''' <summary>
47: ''' Структура информации о сборке в Microsoft.CLRAdmin.
48: ''' </summary>
49: Friend Class A_OneAssemblyInfo
50: ' Динамическая привязка к классу из Microsoft.CLRAdmin.AssemInfo
51: Public Sub New(ByVal AssemInfo As Object)
52: 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)
53: 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)
54: 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)
55: 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)
56: 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)
57: 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)
58: 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)
59: 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)
60: 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)
61: 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)
62: 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)
63: 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)
64: End Sub
65:
66: Dim Name As String
67: Dim Locale As String
68: Dim Codebase As String
69: Dim Modified As String
70: Dim OSType As String
71: Dim OSVersion As String
72: Dim ProcType As String
73: Dim PublicKey As String
74: Dim PublicKeyToken As String
75: Dim Version As String
76: Dim sCustom As String
77: Dim sFusionName As String
78:
79: ''' <summary>
80: ''' Сохранение информации о сборке GAC в базу (True - запись прошла удачно)
81: ''' </summary>
82: Public Function Save(ByVal CMD As CMD_GAC) As Boolean
83: Return CMD.Write(Name, Version, sFusionName)
84: End Function
85:
86: End Class
87:
88: ''' <summary>
89: ''' Описание COM-классов, зарегистрированных в системе
90: ''' </summary>
91: Friend Class A_Win32_ClassicCOMClassSetting ' Win32_COMSetting
92: Public Sub New(ByVal X As System.Management.ManagementObject)
93: AppID = X.GetPropertyValue("AppID")
94: AutoConvertToClsid = X.GetPropertyValue("AutoConvertToClsid")
95: AutoTreatAsClsid = X.GetPropertyValue("AutoTreatAsClsid")
96: Caption = X.GetPropertyValue("Caption")
97: ComponentId = X.GetPropertyValue("ComponentId")
98: Control = X.GetPropertyValue("Control")
99: DefaultIcon = X.GetPropertyValue("DefaultIcon")
100: Description = X.GetPropertyValue("Description")
101: InprocHandler = X.GetPropertyValue("InprocHandler")
102: InprocHandler32 = X.GetPropertyValue("InprocHandler32")
103: InprocServer = X.GetPropertyValue("InprocServer")
104: InprocServer32 = X.GetPropertyValue("InprocServer32")
105: Insertable = X.GetPropertyValue("Insertable")
106: JavaClass = X.GetPropertyValue("JavaClass")
107: LocalServer = X.GetPropertyValue("LocalServer")
108: LocalServer32 = X.GetPropertyValue("LocalServer32")
109: LongDisplayName = X.GetPropertyValue("LongDisplayName")
110: ProgId = X.GetPropertyValue("ProgId")
111: SettingID = X.GetPropertyValue("SettingID")
112: ShortDisplayName = X.GetPropertyValue("ShortDisplayName")
113: ThreadingModel = X.GetPropertyValue("ThreadingModel")
114: ToolBoxBitmap32 = X.GetPropertyValue("ToolBoxBitmap32")
115: TreatAsClsid = X.GetPropertyValue("TreatAsClsid")
116: TypeLibraryId = X.GetPropertyValue("TypeLibraryId")
117: Version = X.GetPropertyValue("Version")
118: VersionIndependentProgId = X.GetPropertyValue("VersionIndependentProgId")
119: End Sub
120:
121: Dim AppID As String
122: Dim AutoConvertToClsid As String
123: Dim AutoTreatAsClsid As String
124: Dim Caption As String
125: Dim ComponentId As String
126: Dim Control As Boolean
127: Dim DefaultIcon As String
128: Dim Description As String
129: Dim InprocHandler As String
130: Dim InprocHandler32 As String
131: Dim InprocServer As String
132: Dim InprocServer32 As String
133: Dim Insertable As Boolean
134: Dim JavaClass As Boolean
135: Dim LocalServer As String
136: Dim LocalServer32 As String
137: Dim LongDisplayName As String
138: Dim ProgId As String
139: Dim SettingID As String
140: Dim ShortDisplayName As String
141: Dim ThreadingModel As String
142: Dim ToolBoxBitmap32 As String
143: Dim TreatAsClsid As String
144: Dim TypeLibraryId As String
145: Dim Version As String
146: Dim VersionIndependentProgId As String
147:
148: ''' <summary>
149: ''' Сохранение информациии о COM-обьекте в базу (True - запись прошла успешно)
150: ''' </summary>
151: Public Function Save(ByVal CMD As CMD_COM) As Boolean
152: Return CMD.Write(AppID, AutoConvertToClsid, AutoTreatAsClsid, Caption, ComponentId, Control, _
153: DefaultIcon, Description, InprocHandler, InprocHandler32, InprocServer, _
154: InprocServer32, Insertable, JavaClass, LocalServer, LocalServer32, LongDisplayName, _
155: ProgId, SettingID, ShortDisplayName, ThreadingModel, ToolBoxBitmap32, TreatAsClsid, _
156: TypeLibraryId, Version, VersionIndependentProgId)
157: End Function
158:
159: End Class
160:
161: ''' <summary>
162: ''' Зафиксировать автоматически установленные хотфиксы
163: ''' </summary>
164: ''' <remarks></remarks>
165: Friend Class A_Win32_QuickFixEngineering ' CIM_LogicalElement
166: Public Sub New(ByVal x As System.Management.ManagementObject)
167: Caption = x.GetPropertyValue("Caption")
168: CSName = x.GetPropertyValue("CSName")
169: Description = x.GetPropertyValue("Description")
170: FixComments = x.GetPropertyValue("FixComments")
171: HotFixID = x.GetPropertyValue("HotFixID")
172: InstallDate = x.GetPropertyValue("InstallDate")
173: InstalledBy = x.GetPropertyValue("InstalledBy")
174: InstalledOn = x.GetPropertyValue("InstalledOn")
175: Name = x.GetPropertyValue("Name")
176: ServicePackInEffect = x.GetPropertyValue("ServicePackInEffect")
177: Status = x.GetPropertyValue("Status")
178: End Sub
179:
180: Dim Caption As String
181: Dim CSName As String
182: Dim Description As String
183: Dim FixComments As String
184: Dim HotFixID As String
185: Dim InstallDate As DateTime
186: Dim InstalledBy As String
187: Dim InstalledOn As String
188: Dim Name As String
189: Dim ServicePackInEffect As String
190: Dim Status As String
191:
192: ''' <summary>
193: ''' Сохранение информации о хотфиксах в базу (True - запись прошла удачно)
194: ''' </summary>
195: Public Function Save(ByVal CMD As CMD_Hotfix) As Boolean
196: Return CMD.Write(Caption, CSName, Description, FixComments, HotFixID, _
197: InstallDate, InstalledBy, InstalledOn, Name, ServicePackInEffect, Status)
198: End Function
199:
200: End Class
201:
202: ''' <summary>
203: ''' Все установленные в системе драйвера
204: ''' </summary>
205: Friend Class A_Win32_SystemDriver
206: Public Sub New(ByVal x As System.Management.ManagementObject)
207: AcceptPause = x.GetPropertyValue("AcceptPause")
208: AcceptStop = x.GetPropertyValue("AcceptStop")
209: Caption = x.GetPropertyValue("Caption")
210: CreationClassName = x.GetPropertyValue("CreationClassName")
211: Description = x.GetPropertyValue("Description")
212: DesktopInteract = x.GetPropertyValue("DesktopInteract")
213: DisplayName = x.GetPropertyValue("DisplayName")
214: ErrorControl = x.GetPropertyValue("ErrorControl")
215: ExitCode = x.GetPropertyValue("ExitCode")
216: InstallDate = x.GetPropertyValue("InstallDate")
217: Name = x.GetPropertyValue("Name")
218: PathName = x.GetPropertyValue("PathName")
219: ServiceSpecificExitCode = x.GetPropertyValue("ServiceSpecificExitCode")
220: ServiceType = x.GetPropertyValue("ServiceType")
221: Started = x.GetPropertyValue("Started")
222: StartMode = x.GetPropertyValue("StartMode")
223: StartName = x.GetPropertyValue("StartName")
224: State = x.GetPropertyValue("State")
225: Status = x.GetPropertyValue("Status")
226: SystemCreationClassName = x.GetPropertyValue("SystemCreationClassName")
227: SystemName = x.GetPropertyValue("SystemName")
228: TagId = x.GetPropertyValue("TagId")
229: End Sub
230:
231: Dim AcceptPause As Boolean
232: Dim AcceptStop As Boolean
233: Dim Caption As String
234: Dim CreationClassName As String
235: Dim Description As String
236: Dim DesktopInteract As Boolean
237: Dim DisplayName As String
238: Dim ErrorControl As String
239: Dim ExitCode As UInt32
240: Dim InstallDate As DateTime
241: Dim Name As String
242: Dim PathName As String
243: Dim ServiceSpecificExitCode As UInt32
244: Dim ServiceType As String
245: Dim Started As Boolean
246: Dim StartMode As String
247: Dim StartName As String
248: Dim State As String
249: Dim Status As String
250: Dim SystemCreationClassName As String
251: Dim SystemName As String
252: Dim TagId As UInt32
253:
254: ''' <summary>
255: ''' Сохранение информации о драйвере в базу (True - запись прошла успешно)
256: ''' </summary>
257: Public Function Save(ByVal CMD As CMD_DRV) As Boolean
258: Return CMD.Write(AcceptPause, AcceptStop, Caption, CreationClassName, Description, DesktopInteract, _
259: DisplayName, ErrorControl, ExitCode, InstallDate, Name, PathName, _
260: ServiceSpecificExitCode, ServiceType, Started, StartMode, StartName, State, _
261: Status, SystemCreationClassName, SystemName, TagId)
262: End Function
263:
264: End Class
265:
266: ''' <summary>
267: ''' Службы системы
268: ''' </summary>
269: Friend Class A_Win32_Service ' Win32_BaseService
270: Public Sub New(ByVal x As System.Management.ManagementObject)
271: AcceptPause = x.GetPropertyValue("AcceptPause")
272: AcceptStop = x.GetPropertyValue("AcceptStop")
273: Caption = x.GetPropertyValue("Caption")
274: CheckPoint = x.GetPropertyValue("CheckPoint")
275: CreationClassName = x.GetPropertyValue("CreationClassName")
276: Description = x.GetPropertyValue("Description")
277: DesktopInteract = x.GetPropertyValue("DesktopInteract")
278: DisplayName = x.GetPropertyValue("DisplayName")
279: ErrorControl = x.GetPropertyValue("ErrorControl")
280: ExitCode = x.GetPropertyValue("ExitCode")
281: InstallDate = x.GetPropertyValue("InstallDate")
282: Name = x.GetPropertyValue("Name")
283: PathName = x.GetPropertyValue("PathName")
284: ProcessId = x.GetPropertyValue("ProcessId")
285: ServiceSpecificExitCode = x.GetPropertyValue("ServiceSpecificExitCode")
286: ServiceType = x.GetPropertyValue("ServiceType")
287: Started = x.GetPropertyValue("Started")
288: StartMode = x.GetPropertyValue("StartMode")
289: StartName = x.GetPropertyValue("StartName")
290: State = x.GetPropertyValue("State")
291: Status = x.GetPropertyValue("Status")
292: SystemCreationClassName = x.GetPropertyValue("SystemCreationClassName")
293: SystemName = x.GetPropertyValue("SystemName")
294: TagId = x.GetPropertyValue("TagId")
295: WaitHint = x.GetPropertyValue("WaitHint")
296: End Sub
297:
298:
299: Dim AcceptPause As Boolean
300: Dim AcceptStop As Boolean
301: Dim Caption As String
302: Dim CheckPoint As UInt32
303: Dim CreationClassName As String
304: Dim Description As String
305: Dim DesktopInteract As Boolean
306: Dim DisplayName As String
307: Dim ErrorControl As String
308: Dim ExitCode As UInt32
309: Dim InstallDate As DateTime
310: Dim Name As String
311: Dim PathName As String
312: Dim ProcessId As UInt32
313: Dim ServiceSpecificExitCode As UInt32
314: Dim ServiceType As String
315: Dim Started As Boolean
316: Dim StartMode As String
317: Dim StartName As String
318: Dim State As String
319: Dim Status As String
320: Dim SystemCreationClassName As String
321: Dim SystemName As String
322: Dim TagId As UInt32
323: Dim WaitHint As UInt32
324:
325: ''' <summary>
326: ''' Сохранение информации о сервисе системы (True если запись прошла успешно)
327: ''' </summary>
328: Public Function Save(ByVal CMD As CMD_Serv) As Boolean
329: Return CMD.Write(AcceptPause, AcceptStop, Caption, CheckPoint, CreationClassName, _
330: Description, DesktopInteract, DisplayName, ErrorControl, ExitCode, _
331: InstallDate, Name, PathName, ProcessId, ServiceSpecificExitCode, ServiceType, _
332: Started, StartMode, StartName, State, Status, SystemCreationClassName, _
333: SystemName, TagId, WaitHint)
334: End Function
335:
336: End Class
337:
338: ''' <summary>
339: ''' Информация о директории
340: ''' </summary>
341: Friend Class A_DirInfo
342:
343: Public Sub New(ByVal D As System.IO.DirectoryInfo)
344: Dir = D.FullName
345: CreationTime = D.CreationTime
346: LastWriteTime = D.LastWriteTime
347: End Sub
348:
349: Dim Dir As String
350: Dim CreationTime As DateTime
351: Dim LastWriteTime As DateTime
352:
353: ''' <summary>
354: ''' Запись в базу информации об одной директории
355: ''' </summary>
356: Public Function Save(ByVal CMD As CMD_Dir) As Boolean
357: Return CMD.Write(Dir, CreationTime, LastWriteTime)
358: End Function
359: End Class
360:
361: ''' <summary>
362: ''' Информация о файле
363: ''' </summary>
364: Friend Class A_FileInfo
365:
366: Public Sub New(ByVal F As System.IO.FileInfo)
367: Dir = F.FullName
368: FileName = F.Name
369: CreationTime = F.CreationTime
370: LastWriteTime = F.LastWriteTime
371: Length = F.Length
372: Hash = GetHash(F.FullName.ToString)
373: End Sub
374:
375: Dim Dir As String
376: Dim FileName As String
377: Dim CreationTime As DateTime
378: Dim LastWriteTime As DateTime
379: Dim Length As Long
380: Dim Hash() As Byte
381:
382: ''' <summary>
383: ''' Сохранение информации об одном файле (True если запись прошла удачно)
384: ''' </summary>
385: Public Function Save(ByVal CMD As CMD_File) As Boolean
386: Return CMD.Write(Dir, FileName, CreationTime, LastWriteTime, Length, Hash)
387: End Function
388:
389: ''' <summary>
390: ''' Расчет MD5-хеша файла - 16 байт (или нули, если файл не открывается)
391: ''' </summary>
392: Function GetHash(ByVal FileName As String) As Byte() 'SHA1 - 20 байт, но считается дольше
393: Try
394: Dim MD5 As System.Security.Cryptography.MD5 = Security.Cryptography.MD5.Create
395: Dim FS As New System.IO.FileStream(FileName, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
396: Return MD5.ComputeHash(FS)
397: FS.Close()
398: Catch ex As Exception
399: 'занято, открыть низзя
400: Dim X(15) As Byte
401: Return X
402: End Try
403: End Function
404:
405: End Class
Дополнительные сведения об этой утилите смотрите в описании от 2006-го года. Сгрузить ее в откомпилированном виде можно отсюда.
|