I Create a Map File named 'Shared_Memory' with CreateFileMapping( ).
Then use the following code try to lock it..
procedure LockMap(var hMutex:THandle);
begin
hMutex := CreateMutex(nil, false, 'Shared_Memory')
if hMutex = 0 then
begin
ShowMessage('Failed');
Result := false;
end
else
begin
if WaitForSingleObject(hMutex,REQUEST_TIMEOUT) = WAIT_FAILED
then
begin
// timeout
ShowMessage('Can't lock memory mapped file');
Result := false;
end
end;
end;
but the hMuteX aloways retun 0, lock failed.
Why lock failed? What exactlly Lock Map File does? Does it lock the Map
File and not allow other applications to read/write the Map File?
Thanks,
Daniel