动
动力汽车
Unregistered / Unconfirmed
GUEST, unregistred user!
这是一个Unit单元的文件,编译的时候总是报:BEGIN expected but END found错误,但是我实在找不出哪里的begin跟end不匹配的,请各位帮我找找看,多谢
unit ShareMem;
interface
uses
Windows,SysUtils;
type
TShareData = integer;
PShareData = ^TShareData;
const
SHAREDATA_SIZE = SizeOf(TShareData);
MapFileNamw = 'DLLMemTest';
implementation
var
MapHandle:THandle;
ShareDataShareData;
procedure OpenShareData;
procedure CloseShareData;
procedure OpenShareData;
begin
MapHandle := CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,SHAREDATA_SIZE,MapFileNamw);
if MapHandle = 0 then
Raise Exception.Create('创建公用数据的Buffer不成功');
ShareData := MapViewOfFile(MapHandle,File_Map_Write,0,0,SHAREDATA_SIZE);
end;
procedure CloseShareData;
begin
UnMapViewOfFile(ShareData);
CloseHandle(MapHandle);
end;
procedure SetShareData(value:TShareData);stdcall;
begin
ShareData^:=value;
end;
function GetShareData:TShareData;stdcall;
begin
Result := ShareData^;
end;
procedure DLLEntryPoint(ReasonWord);
begin
case Reason of
DLL_PROCESS_ATTACH:OpenShareData;
DLL_PROCESS_DETACH:CloseShareData;
end;
end;
end.
unit ShareMem;
interface
uses
Windows,SysUtils;
type
TShareData = integer;
PShareData = ^TShareData;
const
SHAREDATA_SIZE = SizeOf(TShareData);
MapFileNamw = 'DLLMemTest';
implementation
var
MapHandle:THandle;
ShareDataShareData;
procedure OpenShareData;
procedure CloseShareData;
procedure OpenShareData;
begin
MapHandle := CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,SHAREDATA_SIZE,MapFileNamw);
if MapHandle = 0 then
Raise Exception.Create('创建公用数据的Buffer不成功');
ShareData := MapViewOfFile(MapHandle,File_Map_Write,0,0,SHAREDATA_SIZE);
end;
procedure CloseShareData;
begin
UnMapViewOfFile(ShareData);
CloseHandle(MapHandle);
end;
procedure SetShareData(value:TShareData);stdcall;
begin
ShareData^:=value;
end;
function GetShareData:TShareData;stdcall;
begin
Result := ShareData^;
end;
procedure DLLEntryPoint(ReasonWord);
begin
case Reason of
DLL_PROCESS_ATTACH:OpenShareData;
DLL_PROCESS_DETACH:CloseShareData;
end;
end;
end.