T_OWN_INADDR = record
S_un_b: SunB;
S_un_w: SunW;
S_addr: Integer;
end;
// Prozedur in der Bedienanwendung
procedure MakeMMF(own_inaddr: T_OWN_INADDR);
var
hMap: Cardinal;
MapView: Pointer;
tmp_inaddr: T_OWN_INADDR;
inaddr: in_addr;
begin
hMap := CreateFileMapping(INVALID_HANDLE_VALUE, nil, PAGE_READWRITE, 0, SizeOf(T_OWN_INADDR), 'ipu7');
MapView := MapViewOfFile(hMap, FILE_MAP_WRITE, 0, 0, 0);
if Assigned(MapView) then
begin
OutputDebugString('MMF erfolgreich erstellt!');
CopyMemory(MapView, @own_inaddr, SizeOf(T_OWN_INADDR));
end;
CloseHandle(hMap);
end;
// Prozedur in der
DLL die eingenistet wird.
procedure ReadMMF;
var
hMap: Cardinal;
MapView: Pointer;
tmp_inaddr: T_OWN_INADDR;
inaddr: in_addr;
begin
hMap := OpenFileMapping(FILE_MAP_READ, False, 'ipu7');
MapView := MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0);
if Assigned(MapView) then
begin
OutputDebugString('MMF erfolgreich geöffnet!');
CopyMemory(@tmp_inaddr, MapView, SizeOf(T_OWN_INADDR));
AdapterAddress.S_un_b := tmp_inaddr.S_un_b;
AdapterAddress.S_un_w := tmp_inaddr.S_un_w;
AdapterAddress.S_addr := tmp_inaddr.S_addr;
UnMapViewOfFile(MapView);
CloseHandle(hMap);
end;
end;