vb.net遍历进程 vb遍历文件夹的所有文件-成都快上网建站

vb.net遍历进程 vb遍历文件夹的所有文件

vb.net中如何遍历程序窗体中的控件?并读写控件的数据。

Public Sub GetAllControls(ByVal InContainer As Control, ByRef RecieveList As ListBox)

创新互联是一家集网站建设,江岸企业网站建设,江岸品牌网站建设,网站定制,江岸网站建设报价,网络营销,网络优化,江岸网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

For i As Integer = 0 To InContainer.Controls.Count - 1

If InContainer.Controls.Item(i).Text  "" Then

GetList.Items.Add(InContainer.Controls.Item(i).Text  vbCrLf)

End If

If InContainer.Controls.Item(i).Controls.Count  0 Then

GetAllControls(InContainer.Controls.Item(i), GetList)

End If

Next

End Sub

这段代码可行,但不能遍历菜单和工具栏,要按需要修改

VB关进程

'你要关闭什么进程

'就写

'Call taskkill("进程名.exe")

'注意大小写啊

Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long

Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long

Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long

Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long

Private Type PROCESSENTRY32

dwSize As Long

cntUsage As Long

th32ProcessID As Long

th32DefaultHeapID As Long

th32ModuleID As Long

cntThreads As Long

th32ParentProcessID As Long

pcPriClassBase As Long

dwFlags As Long

szExeFile As String * 1024

End Type

Const TH32CS_SNAPHEAPLIST = H1

Const TH32CS_SNAPPROCESS = H2

Const TH32CS_SNAPTHREAD = H4

Const TH32CS_SNAPMODULE = H8

Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)

Const TH32CS_INHERIT = H80000000

Dim pid As Long

Dim pname As String

'-------------结束进程通用函数 注意进程名要区分大小写

Private Sub taskkill(ByVal taskname As String)

Dim my As PROCESSENTRY32

Dim l As Long

Dim l1 As Long

Dim flag As Boolean

Dim mName As String

Dim i As Integer

l = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)

If l Then

my.dwSize = 1060

If (Process32First(l, my)) Then '遍历第一个进程

Do

i = InStr(1, my.szExeFile, Chr$(0))

mName = LCase$(Left$(my.szExeFile, i - 1))

If mName = LCase$(taskname) Then

pid = my.th32ProcessID

pname = mName

Dim mProcID As Long

mProcID = OpenProcess(1, -1, pid)

TerminateProcess mProcID, 0

flag = True

Exit Function

Else

flag = False

End If

Loop Until (Process32Next(l, my) 1) '遍历所有进程知道返回值为False

End If

l1 = CloseHandle(l)

End If

End Sub

Private Sub Command1_Click()

Call taskkill("NOTEPAD.EXE")

'这个是关闭记事本进程的

End Sub

这是我回答的 复制自己回答的内容不算复制吧?????

vb.net 遍历正在运行的虽有窗口和句柄

For Each i As System.Diagnostics.Process In System.Diagnostics.Process.GetProcesses

Next


名称栏目:vb.net遍历进程 vb遍历文件夹的所有文件
文章来源:http://kswjz.com/article/dojjcss.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流