C# Kernel32 导出函数

来源:互联网 发布:掉头发 洗发水 知乎 编辑:程序博客网 时间:2024/06/06 04:03
[csharp] view plaincopy
  1. /// <summary>  
  2.     /// Kernel32导出函数  
  3.     /// </summary>  
  4.     public class Kernel32  
  5.     {  
  6.         [DllImport("KERNEL32.DLL ")]  
  7.         public static extern IntPtr CreateToolhelp32Snapshot(uint flags, uint processid);  
  8.   
  9.         [DllImport("KERNEL32.DLL ")]  
  10.         public static extern int CloseHandle(IntPtr handle);  
  11.   
  12.         [DllImport("KERNEL32.DLL ")]  
  13.         public static extern int Process32First(IntPtr handle, ref   ProcessEntry32 pe);  
  14.   
  15.         [DllImport("KERNEL32.DLL ")]  
  16.         public static extern int Process32Next(IntPtr handle, ref   ProcessEntry32 pe);  
  17.   
  18.   
  19.         [StructLayout(LayoutKind.Sequential)]  
  20.         public struct ProcessEntry32  
  21.         {  
  22.             public uint dwSize;  
  23.             public uint cntUsage;  
  24.             public uint th32ProcessID;  
  25.             public IntPtr th32DefaultHeapID;  
  26.             public uint th32ModuleID;  
  27.             public uint cntThreads;  
  28.             public uint th32ParentProcessID;  
  29.             public int pcPriClassBase;  
  30.             public uint dwFlags;  
  31.   
  32.             [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]  
  33.             public string szExeFile;  
  34.         };  
  35.     }  
0 1
原创粉丝点击