Question: execute this code in Delphi programming language with screen shot of result please: unit UnMW; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

execute this code in Delphi programming language with screen shot of result please:

unit UnMW;

interface

uses

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

Dialogs, StdCtrls;

type

TForm1 = class(TForm)

Edit1: TEdit;

Label1: TLabel;

Label2: TLabel;

Edit2: TEdit;

Button1: TButton;

Button2: TButton;

procedure Button2Click(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

var

mSize : Cardinal;

MemPtr : Pointer;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);

begin

mSize := Length(Edit1.Text) + 1;

MemPtr := VirtualAlloc(NIL, mSize, MEM_COMMIT, PAGE_READWRITE);

VirtualLock(MemPtr, mSize);

CopyMemory(MemPtr, PChar(Edit1.Text), mSize);

VirtualUnlock(MemPtr, mSize);

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

if MemPtr <> NIL then

VirtualFree(MemPtr, MDIChildCount, MEM_RELEASE);

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

if MemPtr = NIL then

ShowMessage(' ')

else

begin

VirtualLock(MemPtr, mSize);

Edit2.SetTextBuf(MemPtr);

VirtualUnlock(MemPtr, mSize);

end;

end;

end.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!