//或
Assembly assembly = Assembly.GetExecutingAssembly()//当前程序集
foreach (Type 高猜type in assembly.GetTypes())
{
Console.WriteLine(type.FullName)
//if(type.FullName.EndsWith(Student))
戚告型 友凳 Console.WriteLine("found")
}
用到了ToolHelpAPI函数虚睁和结构,函数为:CreateToolhelp32Snapshot、Process32First、Process32Next和普通API CloseHandle。结构为:PROCESSENTRY32。 '进程结构定义 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long'进程ID th32DefaultHeapID As Long'堆栈ID th32ModuleID As Long'模块ID cntThreads As Long th32ParentProcessID As Long'父进程ID pcPriClassBase As Long dwFlags As Long szExeFile As String * 260 End Type 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 Sub CloseHandle Lib "kernel32" (ByVal hPass As Long) Private Const TH32CS_SNAPPROCESS = &H2&Private Sub EnumProcess() Dim SnapShot As Long Dim NextProcess As Long Dim PE As PROCESSENTRY32 '创建进程快照 SnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) '如果队列不为空则搜索差桥岁 If SnapShot <>-1 Then '设置进程结构长度 PE.dwSize = Len(PE) '获取首个进程 NextProcess = Process32First(SnapShot, PE) Do While NextProcess ,可对进程序做相应处理 '获取下一个 NextProcess = Process32Next(SnapShot, PE) Loop '释放进程句柄 CloseHandle (SnapShot) End If End Sub欢迎分享,转载请注明来源:内存溢出
评论列表(0条)