(Gast)
n/a Beiträge
|
Re: Anzahl von Semaphore-Objekten bestimmen.
27. Sep 2004, 00:14
Delphi-Quellcode:
const
SemaphoreBasicInformation = 0;
type
SEMAPHORE_BASIC_INFORMATION = record
CurrentCount: Integer;
MaximumCount: Integer;
end;
PSEMAPHORE_BASIC_INFORMATION = ^SEMAPHORE_BASIC_INFORMATION;
function NtQuerySemaphore(SemaphoreHandle: THandle;
SemaphoreInformationClass: ULONG;
SemaphoreInformation: Pointer;
SemaphoreInformationLength: ULONG;
ReturnLength: PULONG): Integer; stdcall; external 'ntdll.dll';
function RtlNtStatusToDosError(StatusCode: Integer): DWORD; stdcall; external 'ntdll.dll';
function GetSemaphoreInfo(hSemaphore: THandle; var CurrentCount: Integer; var MaximumCount: Integer): Boolean;
var
sbi: SEMAPHORE_BASIC_INFORMATION;
Status: Integer;
begin
Result := false;
Status := NtQuerySemaphore(hSemaphore,
SemaphoreBasicInformation,
@sbi,
SizeOf(SEMAPHORE_BASIC_INFORMATION),
nil);
if Status >= 0 then
begin
CurrentCount := sbi.CurrentCount;
MaximumCount := sbi.MaximumCount;
Result := true;
end
else
SetLastError(RtlNtStatusToDosError(Status));
end;
|
|
Zitat
|