getprocessheapu.pas
来自「delphi win32api编程」· PAS 代码 · 共 46 行
PAS
46 行
unit GetProcessHeapu;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, HeapConst, Grids;
type
TForm1 = class(TForm)
Button1: TButton;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
type
BufferType = array[0..63] of byte; // defines the buffer type
var
Buffer: ^BufferType; // the buffer variable
iLoop: Integer; // general loop control variable
begin
{allocate memory from the heap of the calling process}
Buffer := HeapAlloc(GetProcessHeap, HEAP_ZERO_MEMORY, sizeof(BufferType));
{display the default values from the new buffer (should be all zeros)}
for iLoop := 0 to 63 do
StringGrid1.Cells[iLoop, 0] := IntToStr(Buffer^[iLoop]);
{return the memory}
HeapFree(GetProcessHeap, 0, Buffer);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?