Fórum Alterar hora no Windows!! #243392
15/07/2004
0
Como faço para alterar a hora do windows via delphi??
agradeço a atenção..
Cabelo
Cabelo
Curtir tópico
+ 0Posts
15/07/2004
Ursulasobrinho
{Permite que você altere a data e a hora do sistema}
var
tSetDate: TDateTime;
vDateBias: Variant;
tSetTime: TDateTime;
vTimeBias: Variant;
tTZI: TTimeZoneInformation;
tST: TSystemTime;
begin
GetTimeZoneInformation(tTZI);
vDateBias := tTZI.Bias / 1440;
tSetDate := tDate + vDateBias;
vTimeBias := tTZI.Bias / 1440;
tSetTime := tTime + vTimeBias;
with tST do
begin
wYear := StrToInt(FormatDateTime(´yyyy´, tSetDate));
wmonth := StrToInt(FormatDateTime(´mm´, tSetDate));
wDay := StrToInt(FormatDateTime(´dd´, tSetDate));
wHour := StrToInt(FormatDateTime(´hh´, tSettime));
wMinute := StrToInt(FormatDateTime(´nn´, tSettime));
wSecond := StrToInt(FormatDateTime(´ss´, tSettime));
wMilliseconds := 0;
end;
SystemDateTime := SetSystemTime(tST);
end;
Gostei + 0
15/07/2004
Cabelo
ao menos com o micro ligado..
não fiz o teste em reiniciar o micro.. mesmo que funcione assim, não poderei usar, pois preciso fazer isso com o micro ligado, além do quê o computador é atualizado a hora com a hora da rede..
vc sabe como fazer com o micro ligado?
Agradeço sua atenção..
Cabelo
Gostei + 0
15/07/2004
Misael
procedure TForm1.Button1Click(Sender: TObject);
begin
SetNewTime(1998,2,10,18,07);
end;
function SetNewTime(Ano, Mes, Dia, hour, minutes: word): Boolean;
var
st:TSYSTEMTIME;
begin
GetLocalTime(st);
st.wYear := Ano;
st.wMonth := Mes;
st.wDay := Dia;
st.wHour := hour;
st.wMinute := minutes;
if not SetLocalTime(st) then
Result := False
else
Result := True;
end;
Gostei + 0
16/07/2004
Cabelo
obrigado
Cabelo
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)