Einzelnen Beitrag anzeigen

Larsi

Registriert seit: 10. Feb 2007
2.262 Beiträge
 
Delphi 2007 Professional
 
#4

Re: Daten aus Record auslesen?

  Alt 3. Feb 2009, 14:34
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?
Ein Tag ohne Delphi ist ein verlorener Tag!

Homepage zu meinem neuen Programm: StreamZ
  Mit Zitat antworten Zitat