新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net监控.log vb程序远程监控

vb.net中如何设计一个监控程序?

以记事本为例

银川网站建设公司创新互联,银川网站设计制作,有大型网站制作公司丰富经验。已为银川近1000家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的银川做网站的公司定做!

Public Class Form1

Public Sub ShellAndWait(ByVal ProcessPath As String)

Dim objProcess As System.Diagnostics.Process

Try

objProcess = New System.Diagnostics.Process()

objProcess.StartInfo.FileName = ProcessPath

objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal

objProcess.Start()

objProcess.WaitForExit()

objProcess.Close()

Catch

MessageBox.Show("无法执行文件 " ProcessPath, "错误")

End Try

End Sub

'监视程序就可以了,若果监视别的窗体的话,用SPY++ 找到句柄,配合FindWindowEx,SendMessage根据其属性做

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

ShellAndWait("Notepad.exe")

MessageBox.Show("笔记本被关闭后我才会出现")

End Sub

End Class

在vb.net 中,记录系统错误日志这个功能怎么实现

Public Sub ShowError(strModule As String, strProcedure As String, lngErrorNumber As Long, strErrorDescription As String, showMsg As String)

'

'错误处理中心过程,写数据库日志表或写日志文件

'

'strModule '模块名称

'strProcedure '过程名称

'lngErrorNumber '错误ID号

'strErrorDescription '错误描述

'showMsg '是否显示本过程内错误显示信息(值:"Y" or "N")

'Error表结构(f001 (Date)发生时间, f002 (nvarchar50)模块名称, f003 (nvarchar50)过程名称, f004 (nvarchar50)错误ID号, _

f005 (nvarchar300)错误描述,f006 (nvarchar50)版 本 号, f007 (nvarchar50)用户名称, f008 (nvarchar50)网卡地址

'ErrorCode表结构 f001 (nvarchar20)错误代码, f002 (nvarchar255)错误信息, f003 (numeric9)错误级别

' 级别说明: '10'以下,一般错误,不影响操作

' '11-20',严重错误,不能操作,程序执行退出

On Error GoTo ErrorHandle

Dim strMessage As String

Dim strCaption As String

Dim sVer As String

Dim intLogFile As Integer

Dim Res As New ADODB.Recordset

Dim ResErrorCode As New ADODB.Recordset

Dim strSQL As String

'对应错误号,从ErrorCode表中找到对应的错误信息,0-1000 错误号保留给VB

DBOpen ResErrorCode, "select * from errorcode where f001='" lngErrorNumber "'"

If Not (ResErrorCode.EOF Or ResErrorCode.BOF) Then

strMessage = ResErrorCode.Fields("f002")

If ResErrorCode.Fields("f003") 10 Then

MsgBox "产生一个严重错误,可能影响到系统的可操作性,请立即联系本系统开发人员!", vbCritical, "严重错误"

End If

End If

'写错误入文件----------------------------

intLogFile = FreeFile

Open App.Path "\" strIni.LogFile For Append As #intLogFile

Print #intLogFile, "***错误"; VBA.Now "*** " "Version:" _

str$(App.Major) "." str$(App.Minor) "." Format(App.Revision, "0000")

Print #intLogFile, "Error: " lngErrorNumber

Print #intLogFile, "Description: " strErrorDescription

Print #intLogFile, "Module: " strModule

Print #intLogFile, "Procedure: " strProcedure

Print #intLogFile, ""

Close #intLogFile

If Len(strMessage) 2 Then strErrorDescription = strMessage

strMessage = "错误: " "(" lngErrorNumber ")" strErrorDescription vbCrLf vbCrLf _

"模块:" strModule "; 过程:" strProcedure

sVer = Trim(str$(App.Major) "." str$(App.Minor) "." _

Format(App.Revision, "0000"))

strCaption = "错误 Version: " sVer

'写错误入数据库表--------------------------

strSQL = "insert into error(f001,f002,f003,f004,f005,f006,f007,f008) values(" _

DateFmtB VBA.Now DateFmtE "," _

IIf(Len(Trim(strModule)) = 0, "null", "'" strModule "'") "," _

IIf(Len(Trim(strProcedure)) = 0, "null", "'" strProcedure "'") "," _

IIf(Len(Trim(lngErrorNumber)) = 0, "null", "'" lngErrorNumber "'") "," _

IIf(Len(Trim(strErrorDescription)) = 0, "null", "'" Replace(strErrorDescription, "'", "") "'") "," _

IIf(Len(Trim(sVer)) = 0, "null", "'" sVer "'") "," _

IIf(Len(Trim(sUserName)) = 0, "null", "'" sUserName "'") "," _

IIf(Len(Trim(sVer)) = 0, "null", "'" EthernetNO "'") ")"

Cn.Execute strSQL

'是否显示未知错误信息

If Trim(UCase(showMsg)) = "Y" Then MsgBox strMessage, vbCritical, strCaption

PROC_EXIT:

Set Res = Nothing

Set ResErrorCode = Nothing

Exit Sub

ErrorHandle:

Resume Next

如何使用VB.NET监控SQL,指定表中特定字段中有新的数据写入进来。谢谢!

这个监控不好弄。

我想的办法就是你写一个触发器,只要有新增的数据,就同时增加到另一个临时表,然后再 VB.NET 里用计时器,每隔几秒就对那个临时表读一次。如果有新增的,就会有提示。

如果不愿写触发器,也可以直接在 VB.NET 里写上语句,将你需要监控的几个字段内容先保存起来,然后再用最新读取的纪录进行比对,这样也行。

请教各位高手,用c#或vb.net如何监视或阻止系统读取某个文件?

都不是C#能够简单做出来的。

相关技术: shell hook, ifs(文件过滤驱动)。


网站栏目:vb.net监控.log vb程序远程监控
网页链接:http://wjwzjz.com/article/doosehd.html
在线咨询
服务热线
服务热线:028-86922220
TOP