receiveunit.pas

来自「Delphi 7经典问题解析」· PAS 代码 · 共 39 行

PAS
39
字号
unit Receiveunit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
 MapPointer:Pointer;
begin
if (OpenFileMapping(FILE_MAP_ALL_ACCESS,False,'MapFileDemo')<>0) then
 begin
  MapPointer:=MapViewOfFile(OpenFileMapping(FILE_MAP_ALL_ACCESS,False,'MapFileDemo'),FILE_MAP_ALL_ACCESS,0,0,0);
  Edit1.Text := PChar (MapPointer);//从共享内存读出内容
 end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?