English
Forum

Time under Windows XP Change

 

Dieter
Zornow
Hi,

has someone a idea How one The Time by Program Change can, NT -Systemen must one Yes the privilege Change. the succeed I do not, though I already some probiert have. it's located probably on the NewState structure. have too a Source of Andreas Hötker found, the functions but neither.

here one lauffähiger Codeausschnitt from my Program
CompileMarkSeparation
set(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

greetings from Bangkok

Dieter
 
Er ist ein Mann wie ein Baum. Sie nennen ihn Bonsai., Win 7 32 bit und Win 7 64 bit, mit XProfan X2
08/28/07  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

341 Views

Untitledvor 0 min.
Uwe Lang08/08/16

Themeninformationen

this Topic has 1 subscriber:

Dieter Zornow (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie