Ich glaube ich mache was falsch. Also hier nochmal Luckies Code:
Delphi-Quellcode:
type
NET_API_STATUS = DWORD;
type
PTimeOfDayInfo = ^TTimeOfDayInfo;
TTimeOfDayInfo =
packed record
tod_elapsedt: DWORD;
tod_msecs: DWORD;
tod_hours: DWORD;
tod_mins: DWORD;
tod_secs: DWORD;
tod_hunds: DWORD;
tod_timezone: Longint;
tod_tinterval: DWORD;
tod_day: DWORD;
tod_month: DWORD;
tod_year: DWORD;
tod_weekday: DWORD;
end;
const
NERR_Success = 0;
netapi32lib = '
netapi32.dll';
// [..]
function NetApiBufferFree(Buffer: Pointer): NET_API_STATUS;
stdcall;
external netapi32lib
name '
NetApiBufferFree';
function NetRemoteTOD(UncServerName: LPCWSTR; BufferPtr: PBYTE): NET_API_STATUS;
stdcall;
external netapi32lib
name '
NetRemoteTOD';
// [..]
function GetRemoteToD(machine: WideString): TTimeOfDayInfo;
var
TimeOfDayInfo: PTimeOfDayInfo;
dwRetValue: DWORD;
begin
dwRetValue := NetRemoteTOD(PWideChar(WideString(Machine)), PBYTE(@TimeOfDayInfo));
if dwRetValue <> NERR_Success
then
raise Exception.Create(SysErrorMessage(dwRetValue));
with TimeOfDayInfo^
do
begin
Result := TimeOfDayInfo^;
NetApiBufferFree(TimeOfDayInfo);
end;
end;
Wenn ich das Ganze in einem Button so aurufe:
Delphi-Quellcode:
var x: TTimeOfDayInfo;
Caption := IntToStr(x.tod_msecs);
kommt immer 4 raus. Weiß jemand wie ich das richtig aufruf?