delphi 获取系统进程模块信息  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi 获取系统进程模块信息


uses

  TlHelp32;

 

procedure TForm1.FormCreate(Sender: TObject);

var

  Pname: string;

  I, Pid: DWORD;

  Prc: TProcessEntry32;

  modu: TModuleEntry32;

  hModu, hand32: THandle;

  Node: TTreeNode;

begin

  try

    i := 0;

    hand32 := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

    Prc.dwSize := SizeOf(Prc);

    if Process32First(hand32, prc) then

    begin

      Pname := string(Prc.szExeFile);

      Pid := Prc.th32ProcessID;

      node := tv1.Items.Add(nil, Pname);

      Inc(i);

      begin

        hModu := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, Pid);

        Modu.dwSize := SizeOf(Modu);

        if Module32First(hModu, modu) then

          tv1.Items.AddChild(Node, modu.szExePath);

        while Module32Next(hModu, modu) do

          tv1.Items.AddChild(Node, modu.szExePath);

      end;

      while process32next(hand32, prc) do

      begin

        inc(i);

        Pname := string(Prc.szExeFile);

        Pid := Prc.th32ProcessID;

        node := tv1.Items.Add(nil, Pname);

        begin

          hModu := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, Pid);

          Modu.dwSize := SizeOf(Modu);

          if Module32First(hModu, modu) then

            while Module32Next(hModu, modu) do

              tv1.Items.AddChild(Node, modu.szExePath);

        end;

      end;

      ShowMessage(IntToStr(i));

    end;

  finally

    CloseHandle(hand32);

    CloseHandle(hModu);

  end;

end;


————————————————


原文链接:https://blog.csdn.net/haiou327/article/details/6684489



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.039944887161255 seconds