Autor Beitrag
webmaker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 205



BeitragVerfasst: Di 22.04.03 11:26 
Hi wie finde ich die Uhrzeit heraus mit nonVCL heraus?
Habe das so probiert:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
  GetMem(buf, BUFSIZE);
  try
   GetLocalTime(time);
   time2 := IntToStr(GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT or TIME_NOSECONDS, @time, nil, buf, sizeof(buf)));
  finally
   FreeMem(buf, BUFSIZE);
  end;

Kommt aber immer 0 heraus!
Danke schon mal

_________________
.::Wissen ist Macht, nichts wissen macht nichts::.
Stefan-M
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Di 22.04.03 13:17 
schau mal unter msdn.microsoft.com/l...e/gettimesysinfo.asp nach. soweit ich das sehe, sollte es zum gewünschten Ergebnis führen.

Musst halt nur noch die Zahl, die TSI_CurrentTime zurückgibt umrechnen in eine Uhrzeit.
Stefan-M
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Di 22.04.03 13:19 
ok, ich geb es zu, es war quark, probier es mit GetSystemTime(DT:DateTime); hab ich damals auch so gemacht - denke ich
webmaker Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 205



BeitragVerfasst: Di 22.04.03 14:02 
ist das dann ein String?

_________________
.::Wissen ist Macht, nichts wissen macht nichts::.
Stefan-M
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Di 22.04.03 14:17 
nee, das ist vom typ DateTime besser SystemTime (weiss nicht, ob die sich nicht doch etwas unterscheiden - m.E. sollten sie das aber nicht), kannst Du aber in einen String umwandeln ->IntToStr(...)

Die einzelnen Komponenten sind:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
  dt : SYSTEMTIME;

dt.wyear : WORD
dt.wMonth : WORD
dt.wDayOfWeek : WORD
dt.wDay : WORD
dt.wHour : WORD 
dt.wMinute : WORD
dt.wSecond : WORD
dt.wMilliseconds : WORD
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 23.04.03 07:44 
So geht´s:
ausblenden Quelltext
1:
2:
GetLocalTime(lSysTime);
FormatTime(GetDlgItem(hwndDlg,IDC_LOCALTIME),lSysTime);

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
//
// Datum, & Uhrzeit
//
var
{$IFDEF DYNAMIC_PCHAR}
  lpBuf: pchar;
  iLen: integer;
{$ELSE}
  lpBuf: array[0..MAX_PATH] of char;
{$ENDIF}


procedure FormatTime(const wnd: HWND; const st: TSystemTime);
begin
{$IFDEF DYNAMIC_PCHAR}
  iLen := GetTimeFormat(LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT,
    @st,nil,nil,0);

  GetMem(lpBuf,iLen);
  try
    ZeroMemory(lpBuf,iLen);

    if(GetTimeFormat(LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT,
      @st,nil,lpBuf,iLen) = iLen) then SetWindowText(wnd,lpBuf);
  finally
    FreeMem(lpBuf,iLen);
  end;
{$ELSE}
  ZeroMemory(@lpBuf,sizeof(lpBuf));

  if(GetTimeFormat(LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT,
    @st,nil,lpBuf,sizeof(lpBuf)) = 0) then
  begin
    // Format "hh:mm:ss" wird als Alternative benutzt
    lstrcpy(lpBuf,pchar(Format('%.2d:%.2d:%.2d',[st.wHour,st.wMinute,st.wSecond])));
  end;

  SetWindowText(wnd,lpBuf);
{$ENDIF}
end;

zu finden in Luckies Win32-API-Tutorials. :)