自己顶一个
用CMD命令读取到盘里然后再读取txt里面的指定内容,如果有就说明在联网通讯,反之就没有,我觉得这样读取很占内存,请高手简化一下,尽量用简化的代码,获得高效的效率,谢谢!
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Const PROCESS_QUERY_INFORMATION = &H400
Const STILL_ALIVE = &H103
Private Sub Command1_Click()
Dim pId As Long, pHnd As Long
If Dir("d:\temp.txt") <> "" Then Kill "d:\temp.txt"
pId = Shell("cmd /c netstat -an>>d:\temp.txt", vbMinimizedFocus)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pId)
Do
Call GetExitCodeProcess(hProcess, ExitCode)
DoEvents
Loop While ExitCode = STILL_ALIVE
Call CloseHandle(hProcess)
Open "d:\temp.txt" For Input As #1
Line Input #1, aa
'MsgBox aa
Close #1
End Sub
就想读取指定这个格式
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
[
本帖最后由 lzb3158 于 2015-2-4 11:46 编辑 ]