Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am working on an application that will deal with dates and time 4

Status
Not open for further replies.

titoneon

MIS
Dec 11, 2009
335
US
Hi Everyone,
Happy new year for all
I am working on an application for Clock in and Clock out(vfp 9.0 spk1) and i want to dissable from the task bar and from the control panel "the date and time properties", on a few computers that will run the application, with the purposes of not allowing the user to cheat, to change the time and date using these options so some computers still running win 2000 pro, Win xp pro and win 7 pro so would like to know where to actually go to disable this ?
Thanks a lot in advance
Ernesto
 
Hi Ernesto,

Well, this is a bit drastic, but if you really want to do it, you can look for the file named timedate.cpl. In Windows XP, it's in the Windows\System32 folder. Then programmatically change its name (using VFP's RENAME command). Then change it back when you have finished.

But I'm sure people here will advise you not to do this - with good reasons. In general, an application program should never interfere with the Windows interface in this way. It is considered bad behaviour, and should be avoided. And think what would happen if your program crashed before you had restored the name. The user would never be able to manually adjust the date or time again.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,
Thanks for getting back, well the reason i need to block users who are going to use the application to Clock-in and out, it is cause they can cheat on changing their computer time in case they got late to work, so i need to disable access to the time to be change and so far as i know it could be in the control panel and in the icon located to the task bar, if i hide the task bar, the smart guys will find them soon, unless there is a third party application that allow me to dissable it and this 3er party application use a password to enable if case i want it, i guess i can dissable using group policy the icon in the task bar to be shown but i don't find how to disable the one in the control panel from the group policy, unless i cab do from the registries, any other suggestion ?
Regards
Ernesto
 
OK, here's a quick idea.

How about ignoring the computer's internal clock. Instead, get the time of day from a time server on the Internet.

This is just off the top of my head, and I haven't had time to think about the details. But there are pleny of websites that will give you the current time (for a given time zone). I use timeanddate.com, but there might be better ones about. When a user logs on or off, you could programmatically download the relevant page from that site, and extract the time of day from it, thus by-passing the internal clock completely.

Just a thought.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yeah, Mike that is not a bad idea.
Thanks
Dave,
So far as i know i can do that while enabled no access to the date and time properties to the icon in the system tray and that should do the trick but they can also change date and time in the control panel date and time icon and i don't find in XP pro how to remove it from there or disable it, maybe you have a hint for that
Thanks
Ernesto
 
I only know as a standard user I have no privilege to change the system date or time. There should be a group policy managing that, not the GUI elements, but the privilege to change the time at all. You also need to set up a BIOS password, though. There still are ways to cheat with a startup DVD (Linux Live system), which also is able to change system clock.

If you want to make sure users have no way to cheat, don't use the system time for your application, but take the time from a server they don't control at all.

Several ways to get the current time exists:

T-SQL Getdate() gives you date/Time of the SQL Server you query, as simple as "SELECT Getdate() as Now" via SQLExec (no table needed).

You can create a file on a server share and use FTIME() to get the time.

The header of a http request to a server gives you the server time in the http response header.

Bye, Olaf.

 
If your app is on a network, and its running off a shared computer (server), you can get the date/time of the server by creating a file on the network and then get the timestamp of the file.

Its been working for me:

Code:
Function GetServerDateTime()
LOCAL lcExecutablePath, lnSpace, lcServerPath, lcFile, lnHandle, lcTime, ldDate, ltDateTime

lcExecutablePath = SYS(16)
lnSpace = AT(" ",lcExecutablePath,2)
lcServerPath = ADDBS(JUSTDRIVE(SUBSTR(lcExecutablePath,lnSpace))) + "YourAppFolder\"
lcFile = ADDBS(lcServerPath) + SYS(3)
lnHandle = FCREATE(lcFile)

IF lnHandle < 0
	FCLOSE(lnHandle)
	IF FILE(lcFile)
		ERASE (lcFile)
	ENDIF
	RETURN DATETIME()	&& couldn't create the server file, so return local time instead
ENDIF

lcTime = FTIME(lcFile)
ldDate = FDATE(lcFile)
ltDateTime = CTOT(DTOC(ldDate) + ' ' + lcTime)

FCLOSE(lnHandle)
ERASE (lcFile)

RETURN ltDateTime

Ez Logic
Michigan
 
I didn't read Olaf's post, i just read it and Olaf suggested same thing (one of them), is to create a file on share server .

my code/post will show you that.

in VFP, that's how i have been getting it. in SQL, i get the GetDate(). Watch out for Timezone offset though.

so you can do this in sql: select DateAdd(hh,?nZoneOffset,GetUTCDate()) as ServerDateTime
assuming nZoneOffset is the time zone offset, ex: -5 for EST time zone etc..


Ez Logic
Michigan
 
You would be better getting the time from somewhere else.

The user could, given the correct rights, simply type TIME 12:43 at a commend prompt or in the
run dialog otherwise.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Hi Olaf,
Yes that is true, i gave a thou to the bios password so i am going to have to put a password on each machine in order the access the Bios setup and second, i need a clarification here, you meant get the date and time from a server that is running Ms SQL server ? is this is the case i don't have a
server running MS SQL. NOW the idea of getting od creating a file on server share and use Ftime is good too.
Thanks
 
Regarding Ez Logic's suggestion of creating a file on the server and then checking its timestamp.

I might be totally wrong about this. But I would think that, if you run a program on a client computer, and that program creates a file and stores it on a server, then the timestamp is going to be that of the client, not of the server.

Can anyone confirm or deny that? I am not able to test it for myself just at the moment.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi

It gets the time/date stamp of the server, or it does here anyway, Windows 7 to Windows 2K Server

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Hi Mike, when i did this about 5 years ago, at first thought, i assumed it would create the file with the client's date/time stamp.

however, i tested this with xp, vista, 7, 8, server 2k3, 2k8, 2012 server. All have the server's timestamp, even when you create the file from a client.

Weird. eh?

Ez Logic
Michigan
 
Hi titoneon,

I suggested "Several ways".
One is to have a SQL Server, yes. But I suggested two others.

Usung any of the methods, you don't need to set up a bios password on every client, as you don't take the system time of any client, but of some server, either a file server, sql server or internet server, any server the user has no control is good to get a time not changed.

Even if you add a bios password users may change the bios time by using another OS started from a live DVD, many Linux systems come as that.

It's much, MUCH, really MUCH simpler to not try to secure the client system from user manipuolations by taking the time from any server, the user has no influence on, eg google.com.

Code:
loXmlHttp = Createobject("MSXML2.XMLHTTP")
loXmlHttp.Open("HEAD", "[URL unfurl="true"]https://www.google.com/?q=",.F.)[/URL]
loXmlHttp.Send()
Do While loXmlHttp.readyState <>4
   DoEvents
Enddo
? loXmlHttp.getResponseHeader("Date")

That string now needs to be parsed to get the time portion, not that hard.

Bye, Olaf.
 
Olaf,
This little piece of code is great but when the date is displayed i am getting the time zone different than the one i need, i need this to be Eastern
Time (US&CANADA), can you tell me what should be the change needed to display it as the one i need ?
Thanks
Ernesto
 
The standard for http headers is to give time in GMT time zone. All you need to apply is the time zone offset to GMT.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top