zoukankan      html  css  js  c++  java
  • Delphi程序流程三(1)(while)PS:顺便写了个最简单的任务管理器(包含申明API 自己申明参数为结构型API 组件LISTVIEW的用法)

    unit Unit1;
    
    interface
    
    uses
      Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ComCtrls;
    
    type
      TForm1 = class(TForm)
        btn1: TButton;
        ListView: TListView;
        procedure btn1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      newitem:TListItem; //超级列表框一定要在这里申明 不知道为什么
      //一个程序只用一次就可以了,放在按纽事件里有BUG  坑爹的
    
    implementation
      type
       Snapshot32=record //记录类型的名称
       A1:Integer;
       A2:Integer;
       A3:Integer;
       A4:Integer;
       A5:Integer;
       A6:Integer;
       A7:Integer;
       A8:Integer;
       A9:Integer;
       A10:array[0..259]of char;
       end;
    
        function CreateToolhelp32Snapshot(x,y: Integer): Integer;
    stdcall; external 'kernel32.dll' name 'CreateToolhelp32Snapshot';
        function Process32Next(x:Integer;VAR y: Snapshot32): Integer;
    stdcall; external 'kernel32.dll' name 'Process32Next';
        function Process32First(x:Integer;VAR y: Snapshot32): Integer;
    stdcall; external 'kernel32.dll' name 'Process32First';
        function CloseHandle(x:Integer): Integer;
    stdcall; external 'kernel32.dll' name 'CloseHandle';
    
    {$R *.dfm}
    
    procedure TForm1.btn1Click(Sender: TObject);
    var i,x:Integer;
        m:string;
        k:Snapshot32;
    begin
        ListView.Clear;
        i:=CreateToolhelp32Snapshot(2,0);
    k.A1:=1024; x:
    =Process32First(i,k) ; while x<>0 do begin newitem:=Listview.Items.Add; //要在循环里放入这个 否则他一直加入的是第 //一行 理解的是 超级列表框添加一行 返回新的行数 下面是新行数的标题 和新 //行数的列添加 //循环后再一次添加新一行 ,返回新的行数………依次这样 //超级列表框增加列表项目在 属性 Columns 里设置 然后必须要把属性ViewStyle //设置为vsreport newitem.Caption:=k.A10; newitem.SubItems.Add(IntToStr(k.A3)); x:=Process32Next(i,k); end; CloseHandle(x); end; end.

    最简单的几个API 几分钟就可以写起 却在Listview的属性上花了太多时间 界面编程 最好用 最人性化的还是易语言 不说了 都是泪
    算是第一个W32程序吧 截图留个纪念

    参考书目:Delphi组件大全PDF及源代码

  • 相关阅读:
    java 中静态变量和实例变量之间的区别
    java 中final 引用不可变,但是引用还是可以发生变化的
    java中char和Unicode之间的关系
    java 中终止内层循环的方法
    ssh 公钥免密码登陆
    关于Python 中unicode 转码的问题
    Python中Unicode码和非Unicode码引起的错误与格式转换
    第一次写博客,怎么写?
    zookeeper实现主-从结构的一般原理
    Python中Tuple的词源有趣探索
  • 原文地址:https://www.cnblogs.com/qq32175822/p/3143482.html
Copyright © 2011-2022 走看看