1 .net c# compact-framework windows-ce
嘿,我正在为我的智能手机开发一个小应用程序,使用 Windows Mobile 6。我试图获取所有当前正在运行的 processec,但方法 CreateToolhelp32Snapshot 总是返回 -1。所以现在我卡住了。我试图在调用 GetLastError() 方法时出错,但该方法返回 0 值。这是我的代码片段。
private const int TH32CS_SNAPPROCESS = 0x00000002;
[DllImport("toolhelp.dll")]
public static extern IntPtr CreateToolhelp32Snapshot(uint flags,
uint processid);
public static Process[] GetProcesses()
{
ArrayList procList = new ArrayList();
IntPtr handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if ((int)handle > 0)
{
try
{
PROCESSENTRY32 peCurr;
PROCESSENTRY32 pe32 = new PROCESSENTRY32();
// get byte array to pass to API call
byte[] peBytes = pe32.ToByteArray();
// get the first process
int retval = Process32First(handle, peBytes);
Run Code Online (Sandbox Code Playgroud)
附带说明一下,智能设备框架的OpenNETCF.ToolHelp 命名空间已实现所有这些并且可以正常工作(以防您不想重新发明轮子)。
| 归档时间: |
|
| 查看次数: |
3874 次 |
| 最近记录: |