Dieter Zornow | ¡Hola,
ha alguien una Concepto cómo el Tiempo por Programa ändern kann, bajo NT -Systemen muss uno sí el Privileg ändern. Das gelingt No, obwohl Yo ya einiges probiert habe. Lo liegt wahrscheinlich a el NewState Struktur. Posesiones auch una Quellcode de Andreas Hötker gefunden, el funktioniert aber auch no.
Hier una lauffähiger Codeausschnitt de mi Programa KompilierenMarcaSeparaciónset(Errorlevel,0)
DEF GETSYSCOLOR(1) !USER32,GetSysColor
DEF GetLocalTime(1) ! Kernel32,GetLocalTime
DEF GetSystemTime(1) ! Kernel32,GetSystemTime
DEF SetLocalTime(1) ! Kernel32,SetLocalTime
DEF SetSystemTime(1) ! Kernel32,SetSystemTime
DEF GetWinVersion(1) ! kernel32,GetVersionExA
DEF LookupPrivilegeValue(3) ! advapi32,LookupPrivilegeValueA
DEF OpenProcessToken(3) ! advapi32,OpenProcessToken
DEF AdjustTokenPrivileges(6) ! advapi32,AdjustTokenPrivileges
DEF GetCurrentProcess(0) ! kernel32,GetCurrentProcess
DEF CloseHandle(1) ! kernel32,CloseHandle
DEF GetLastError(0) ! kernel32,GetLastError
Declare LUID#
proc Allow
Declare Token#,token&,SYSTEM#,Privileg#,NewState#,size#
Dim size#,4
DIM system#,4
DIM token#,4
DIM NewState#,12
DIM LUID#,4
DIM Privileg#,Len(SeSystemtimePrivilege)+1
String Privileg#,0=SeSystemtimePrivilege
String system#,0 =
OpenProcessToken(GetCurrentProcess(),$20 | $8,Token#)
token&=long(token#,0)
LookupPrivilegeValue(system#,Privileg#,luid#)
Long NewState#,0=1
long newstate#,4 = long(luid#,0)+2
Byte NewState#,4=Byte(LUID#,0)
Byte NewState#,5=Byte(LUID#,1)
Byte NewState#,6=Byte(LUID#,2)
Byte NewState#,7=Byte(LUID#,3)
Byte NewState#,8=Byte(LUID#,4)
Byte NewState#,9=Byte(LUID#,5)
Byte NewState#,10=Byte(LUID#,6)
Byte NewState#,11=Byte(LUID#,7)
Long NewState#,8=2
clear luid#
AdjustTokenPrivileges(Token&,0,NewState#,sizeof(luid#),luid#,size#)
CloseHandle(Token&)
Dispose size#
Dispose system#
Dispose NewState#
Dispose Privileg#
endproc
Proc disallow
Declare token&,token#
Dim token#,4
OpenProcessToken(GetCurrentProcess(),$20 | $8,Token#)
token&=long(token#,0)
AdjustTokenPrivileges(Token&,0,luid#,0,0,0)
CloseHandle(Token&)
Dispose LUID#
Dispose token#
endproc
Proc Getplattform
Declare B#,pl&
Dim B#,148
long B#,0 = 148
GetWinVersion(B#)
pl& = long(b#,16)
Dispose B#
Return pl&
endproc
Proc GetWeekday
Parameters day&
Return substr$(Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,day& + 1,,)
endproc
PROC showFiledate
DECLARE DLG&, DIALOGENDE%,Zday&,Zmonth&,Zyear&,Ehour&,Esec&,Eminute&,Ems&
DECLARE Zhour&,Zsec&,Zminute&,Zms&,Ewday&,Eday&,Emonth&,Eyear&,upd&,jn%,ID&
DECLARE Zwday&,change&,bye&,gr1&,gr2&,TEXT2&,TEXT3&,TEXT4&,TEXT6&,TEXT7&,TEXT11&
DIALOGENDE%=0
Proc Gettime
Declare time#
Dim time#,16
GetLocalTime(time#)
settext Eyear&,str$(word(time#,0))
settext Emonth&,str$(word(time#,2))
settext Ewday&,GetWeekday(Word(time#,4))
settext Eday&,str$(word(time#,6))
settext Ehour&,str$(word(time#,8))
settext Eminute&,str$(word(time#,10))
settext Esec&,str$(word(time#,12))
settext Ems&,str$(word(time#,14))
clear time#
GetSystemTime(time#)
settext zyear&,str$(word(time#,0))
settext zmonth&,str$(word(time#,2))
settext zwday&,GetWeekday(Word(time#,4))
settext zday&,str$(word(time#,6))
settext zhour&,str$(word(time#,8))
settext zminute&,str$(word(time#,10))
settext zsec&,str$(word(time#,12))
settext zms&,str$(word(time#,14))
Dispose time#
endproc
Proc settime
Declare time#
Dim time#,16
word time#,0 = Val(Gettext$(Eyear&))
word time#,2 = Val(Gettext$(emonth&))
word time#,4 = 0
word time#,6 = val(Gettext$(eday&))
word time#,8 = val(Gettext$(ehours&))
word time#,10= val(Gettext$(eminute&))
word time#,12 = Val(Gettext$(esec&))
word time#,14 = Val(Gettext$(ems&))
SetLocalTime(time#)
Dispose time#
endproc
WINDOWSTYLE 31
DLG&=CREATE(DIALOG,%HWND,Zeit Information,((%MAXX/2)-(300/2)),((%MAXY/2)-(394/2)),300,394)
USEFONT MS Sans Serif,13,0,0,0,0
SETDIALOGFONT 1
gr1& = CREATE(GROUPBOX,DLG&,Local time,0005,0035,0210,0120)
TEXT2& =CREATE(TEXT,DLG&,Wochentag:,0010,0060,0070,0020)
Ewday& =CREATE(EDIT,DLG&,,0085,0060,0120,0020)
text3& =CREATE(TEXT,DLG&,Datum:,0010,0090,0070,0020)
Eday& =CREATE(EDIT,DLG&,,0085,0090,0020,0020)
Emonth& =CREATE(EDIT,DLG&,,0115,0090,0020,0020)
Eyear& =CREATE(EDIT,DLG&,,0145,0090,0030,0020)
TEXT4& =CREATE(TEXT,DLG&,Zeit:,0010,0120,0070,0020)
Ehour& =CREATE(EDIT,DLG&,,0085,0120,0020,0020)
Eminute& =CREATE(EDIT,DLG&,,0115,0120,0020,0020)
Esec& =CREATE(EDIT,DLG&,,0145,0120,0020,0020)
Ems& =CREATE(EDIT,DLG&,,0175,0120,0030,0020)
gr2& = CREATE(GROUPBOX,DLG&,System time,0005,0158,0210,0120)
TEXT6& =CREATE(TEXT,DLG&,Wochentag:,0010,0181,0070,0020)
Zwday& =CREATE(EDIT,DLG&,,0085,0182,0120,0020)
TEXT11& =CREATE(TEXT,DLG&,Datum:,0010,0215,0070,0020)
Zday& =CREATE(EDIT,DLG&,,0085,0215,0020,0020)
Zmonth& =CREATE(EDIT,DLG&,,0115,0215,0020,0020)
Zyear& =CREATE(EDIT,DLG&,,0145,0215,0030,0020)
TEXT7& =CREATE(TEXT,DLG&,Zeit:,0010,0245,0070,0020)
Zhour& =CREATE(EDIT,DLG&,,0085,0245,0020,0020)
Zminute& =CREATE(EDIT,DLG&,,0115,0245,0020,0020)
Zsec& =CREATE(EDIT,DLG&,,0145,0245,0020,0020)
Zms& =CREATE(EDIT,DLG&,,0175,0245,0030,0020)
change& =CREATE(BUTTON,DLG&,&Lokal Datum und Zeit ändern,0010,0300,0150,0025)
bye& =CREATE(BUTTON,DLG&,&Ende,0165,0300,0070,0025)
upd& = CREATE(BUTTON,DLG&,Stop Update,0035,0010,0150,0025)
enablewindow zwday&,0
enablewindow zday&,0
enablewindow zmonth&,0
enablewindow zyear&,0
enablewindow zhour&,0
enablewindow zminute&,0
enablewindow zsec&,0
enablewindow zms&,0
Id& = Getplattform()
case id& = 2:allow()
Gettime()
SETFOCUS(DLG&)
Settimer 100
WHILENOT DIALOGENDE%
WAITINPUT
case %wmtimer:Gettime()
If (%KEY=2)
DIALOGENDE%= 1
ELSEIF CLICKED(change&)
if gettext$(upd&) = Start Update
Messagebox(Die lokale Zeit wird nun geändert,
der Wochentag kann nicht geändert werden
Wollen Sie die Änderung durchführen,Sicherheitabfrage,262144+36)
case jn% = 6:settime()
else
Messagebox(Bitte erst Update stoppen,Information,262144+64)
endif
ELSEIF CLICKED(upd&)
If gettext$(upd&) = Stop Update
Killtimer
settext upd&, Start Update
else
settext upd&, Stop Update
Settimer 100
endif
ELSEIF CLICKED(bye&)
DIALOGENDE%= 1
ENDIF
endwhile
Killtimer
case id& = 2:disallow()
DESTROYWINDOW(DLG&)
ENDPROC
WINDOWTITLE Zeit Information
WINDOWSTYLE 112
WINDOW 0,pan>-0,0
showFiledate
end
Viele Grüße de Bangkok
Dieter |
|