Page 1 of 1

Change date and time of windows

Posted: Fri Dec 04, 2015 9:52 pm
by PremierePRO
Hello
I could use a little program to change the date and system time , I used the following code

Code: Select all

Structure Time 
  Giorno.w
  Mese.w 
  Anno.w 
  Ora.w 
  Minuti.w 
  Secondi.w 
EndStructure

Dim SetTime.Time(1)
SetTime(1)\Giorno=25
SetTime(1)\Mese=12 
SetTime(1)\Anno=2015
SetTime(1)\Ora=23
SetTime(1)\Minuti=59
SetTime(1)\Secondi=59
but the date of windows does not change ...

where am I wrong ?

Thank you.

__________________________________________________
Code-Tags added
04.12.2015
RSBasic

Re: Change date and time of windows

Posted: Fri Dec 04, 2015 10:34 pm
by infratec
Hi,

you only set some variables in a structured array.

Where is your command to set the system time :?: :?: :?:

Bernd

Re: Change date and time of windows

Posted: Fri Dec 04, 2015 11:26 pm
by ts-soft
As Administrator:

Code: Select all

; enable admin-modus!
CompilerIf Defined(SYSTEMTIME, #PB_Structure) = 0
  Structure SYSTEMTIME
    wYear.w
    wMonth.w
    wDayOfWeek.w
    wDay.w
    wHour.w
    wMinute.w
    wSecond.w
    wMilliseconds.w
  EndStructure
CompilerEndIf

Define SetTime.SYSTEMTIME
SetTime\wDay = 25
SetTime\wMonth = 12
SetTime\wYear = 2015
SetTime\wHour = 23
SetTime\wMinute = 59
SetTime\wSecond = 59

SetLocalTime_(SetTime)

Re: Change date and time of windows

Posted: Sat Dec 05, 2015 12:03 am
by PremierePRO
ts-soft wrote:As Administrator:

Code: Select all

; enable admin-modus!
CompilerIf Defined(SYSTEMTIME, #PB_Structure) = 0
  Structure SYSTEMTIME
    wYear.w
    wMonth.w
    wDayOfWeek.w
    wDay.w
    wHour.w
    wMinute.w
    wSecond.w
    wMilliseconds.w
  EndStructure
CompilerEndIf

Define SetTime.SYSTEMTIME
SetTime\wDay = 25
SetTime\wMonth = 12
SetTime\wYear = 2015
SetTime\wHour = 23
SetTime\wMinute = 59
SetTime\wSecond = 59

SetLocalTime_(SetTime)

I tried , but the time and date of windows do not change .... @:(

Re: Change date and time of windows

Posted: Sat Dec 05, 2015 12:11 am
by ts-soft
This is required:
Image

Re: Change date and time of windows

Posted: Sat Dec 05, 2015 12:13 am
by infratec
Hi,

have you really enabled Administrator mode in Compiler options?

This works here:

Code: Select all

CompilerIf Defined(SYSTEMTIME, #PB_Structure) = 0
  Structure SYSTEMTIME
    wYear.w
    wMonth.w
    wDayOfWeek.w
    wDay.w
    wHour.w
    wMinute.w
    wSecond.w
    wMilliseconds.w
  EndStructure
CompilerEndIf

Define SetTime.SYSTEMTIME
SetTime\wDay = 25
SetTime\wMonth = 12
SetTime\wYear = 2015
SetTime\wHour = 23
SetTime\wMinute = 59
SetTime\wSecond = 59

If SetLocalTime_(@SetTime) = 0
  Debug GetLastError_()
EndIf
If not you see now the error code.

Bernd

Re: Change date and time of windows

Posted: Sat Dec 05, 2015 12:29 am
by PremierePRO
infratec wrote:Hi,

have you really enabled Administrator mode in Compiler options?

This works here:

Code: Select all

CompilerIf Defined(SYSTEMTIME, #PB_Structure) = 0
  Structure SYSTEMTIME
    wYear.w
    wMonth.w
    wDayOfWeek.w
    wDay.w
    wHour.w
    wMinute.w
    wSecond.w
    wMilliseconds.w
  EndStructure
CompilerEndIf

Define SetTime.SYSTEMTIME
SetTime\wDay = 25
SetTime\wMonth = 12
SetTime\wYear = 2015
SetTime\wHour = 23
SetTime\wMinute = 59
SetTime\wSecond = 59

If SetLocalTime_(@SetTime) = 0
  Debug GetLastError_()
EndIf
If not you see now the error code.

Bernd
OK.... :D

PS.



one last thing , if I wanted to add a loop ?

Re: Change date and time of windows

Posted: Sat Dec 05, 2015 12:52 am
by Dude
PremierePRO wrote:if I wanted to add a loop ?
LOL, trying to bypass a time-limited app, eh? ;)

Re: Change date and time of windows

Posted: Sat Dec 05, 2015 11:18 am
by infratec
Are you really sure that you have already programmed before :mrgreen:

Loops in PB:

For Next
While Wend
Repeat Until

With a Delay() between.

Or, if you write a GUI program: AddWindowTimer()

Bernd