Just starting out? Need help? Post your questions and find answers here.
PremierePRO
User
Posts: 28 Joined: Tue Apr 16, 2013 10:31 am
Post
by PremierePRO » Fri Dec 04, 2015 9:52 pm
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
infratec
Always Here
Posts: 7582 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Fri Dec 04, 2015 10:34 pm
Hi,
you only set some variables in a structured array.
Where is your command to set the system time
Bernd
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Fri Dec 04, 2015 11:26 pm
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)
PureBasic 5.73 |
SpiderBasic 2.30 |
Windows 10 Pro (x64) |
Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
PremierePRO
User
Posts: 28 Joined: Tue Apr 16, 2013 10:31 am
Post
by PremierePRO » Sat Dec 05, 2015 12:03 am
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 .... @:(
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Sat Dec 05, 2015 12:11 am
This is required:
PureBasic 5.73 |
SpiderBasic 2.30 |
Windows 10 Pro (x64) |
Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
infratec
Always Here
Posts: 7582 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Sat Dec 05, 2015 12:13 am
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
PremierePRO
User
Posts: 28 Joined: Tue Apr 16, 2013 10:31 am
Post
by PremierePRO » Sat Dec 05, 2015 12:29 am
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....
PS.
one last thing , if I wanted to add a loop ?
Dude
Addict
Posts: 1907 Joined: Mon Feb 16, 2015 2:49 pm
Post
by Dude » Sat Dec 05, 2015 12:52 am
PremierePRO wrote: if I wanted to add a loop ?
LOL, trying to bypass a time-limited app, eh?
infratec
Always Here
Posts: 7582 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Sat Dec 05, 2015 11:18 am
Are you really sure that you have already programmed before
Loops in PB:
For Next
While Wend
Repeat Until
With a Delay() between.
Or, if you write a GUI program: AddWindowTimer()
Bernd