获取进程详细信息 - GetProcessInfo
函数简介
根据指定的pid获取进程详细信息,包括进程名、进程全路径、CPU占用率(百分比)、内存占用量(字节)
接口名称
GetProcessInfo
DLL调用
long GetProcessInfo(long ola, long pid)
参数定义:
ola
(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。pid
(长整型数): 进程ID。
示例:
long strPtr = GetProcessInfo(ola, pid);
if (strPtr != 0) {
// 使用进程信息
// 返回格式: "进程名|进程路径|CPU占用率|内存占用量"
// ...
// 释放内存
FreeStringPtr(strPtr);
}
COM调用
string GetProcessInfo(long pid)
参数定义:
pid
(长整型数): 进程ID。
示例:
process_info = ola.GetProcessInfo(pid)
info_parts = process_info.split("|")
messagebox("进程名: " + info_parts[0] + "\n" +
"进程路径: " + info_parts[1] + "\n" +
"CPU占用率: " + info_parts[2] + "%\n" +
"内存占用量: " + info_parts[3] + "字节")
返回值
字符串:
- 返回格式为 "进程名|进程路径|CPU占用率|内存占用量"
- CPU占用率以百分比表示
- 内存占用量以字节为单位
注意:
- DLL调用返回字符串指针地址,需要调用 FreeStringPtr 接口释放内存