delphi 指针,数组,记录

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;

 

type

  TForm1 = class(TForm)

    btn1: TButton;

    btn2: TButton;

    btn3: TButton;

    procedure btn1Click(Sender: TObject);

    procedure btn2Click(Sender: TObject);

    procedure btn3Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

type

  TVIDEOWALL_DESKTOP = packed record

    lWidth: DWORD;        //Width of the desktop in pixels (read-only).

    lHeight: DWORD;       //Height of the desktop in lines (read-only).

    lBpp: DWORD;          //Bits per pixel value of the desktop (read-only).

    lRefresh: DWORD;      //Refresh rate of the desktop in Hertz (read-only).

    lFlags: DWORD;        //Desktop rendering method.

    lColorKey: DWORD;     //RGB color keyColorKey

  End;

  TPVIDEOWALL_DESKTOP = ^TVIDEOWALL_DESKTOP;

  TArr = array[0..5] of string;

  TPArr = ^TArr;

var

  Form1: TForm1;

  Function Link_GetDesktop(pVideoWallDesktop:TPVIDEOWALL_DESKTOP):longint;stdcall;External'dwclink.dll';

implementation

 

{$R *.dfm}

 

procedure TForm1.btn1Click(Sender: TObject);

var

  nRet : LongInt;

  pVideoWallDesktop:TPVIDEOWALL_DESKTOP;

begin

  GetMem(pVideoWallDesktop,SizeOf(TPVIDEOWALL_DESKTOP));

  nRet := Link_GetDesktop(pVideoWallDesktop);

  FreeMem(pVideoWallDesktop);

end;

 

procedure TForm1.btn2Click(Sender: TObject);

var

  PArr : ^TArr ;

  p : Pointer;

  PArr2 : TPArr;

  Arr2 : TArr;

begin

  GetMem(PArr,SizeOf(TArr));

  GetMem(PArr2,SizeOf(TArr));

  PArr^[0] := 'sss';

  PArr^[1] := 'aaa';

  ShowMessage(PArr^[0][1]);

  ShowMessage(IntToHex(Integer(Parr),8));

  p := Pointer($00b32960);

  ShowMessage(TPArr(p)^[0]);

 

  Arr2 := @PArr2;

  FreeMem(PArr);

  FreeMem(PArr2);

end;

 

procedure TForm1.btn3Click(Sender: TObject);

var

  Ts : TStringList;

begin

  Ts := TStringList.Create;

  Ts.Add('111');

  Ts.Add('222');

  Ts.Add('333');

  Ts.Add('444');

  Ts.Add('555');

  ShowMessage(Ts.Text);

end;

 

end.

 

posted @ 2011-08-10 08:32  perock  阅读(1786)  评论(0编辑  收藏  举报