- Код: Выделить всё
function MyCreateEvent(const AName: string): cardinal;
var
SA: TSecurityAttributes;
SD: TSecurityDescriptor;
begin
if not InitializeSecurityDescriptor(@SD, SECURITY_DESCRIPTOR_REVISION) then
raise Exception.CreateFmt('Error InitializeSecurityDescriptor: %s', [SysErrorMessage(GetLastError)]);
SA.nLength := SizeOf(TSecurityAttributes);
SA.lpSecurityDescriptor := @SD;
SA.bInheritHandle := False;
if not SetSecurityDescriptorDacl(SA.lpSecurityDescriptor, True, nil, False) then
raise Exception.CreateFmt('Error SetSecurityDescriptorDacl: %s', [SysErrorMessage(GetLastError)]);
Result := CreateEvent(@SA, True, True, PChar(AName));
if Result = 0 then
raise Exception.CreateFmt('Error MyCreateEvent: %s', [SysErrorMessage(GetLastError)]);
end;
Под windows он нормально работает и в Делфи и в Лазаре. Код необходим для создания межюзерного, межпроцессного ивента, работающего между юзерами System и 'обычным'
Использую так:
- Код: Выделить всё
WaitEvent := MyCreateEvent('Global\SyncEvent')
Как это перевести для fpc в линуксе?
Сам ивент в линуксе создаю так (не тестировал, правда, пока):
- Код: Выделить всё
function CreateEvent(EventAttributes : Pointer; AManualReset,InitialState : Boolean;const Name : PChar): TEventHandle;
begin
Result := BasicEventCreate(EventAttributes, AManualReset, InitialState, Name);
end;
Как можно создать и передать правильные атрибуты?