473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to get the real system date

How can I get the real system date/time if the user fakes the date, for
example by setting the system date back.
--
Mike
Jun 9 '06 #1
11 12959
Hi,

DateTime.Now is the REAL time, real at least for the local computer.

You can check a time server in the internet ; I don't know if any right now
but I bet that a couple of US institutions give this service for free; and
if the returned time is different thatn the local time you change it.

Note that there will always be a little delta from the time the remote
server sent the time until you process it in your app.

You need to P/Invoke SetSystemTime from the win API

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mike9900" <Mi******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
How can I get the real system date/time if the user fakes the date, for
example by setting the system date back.
--
Mike

Jun 9 '06 #2
SP

"Mike9900" <Mi******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
How can I get the real system date/time if the user fakes the date, for
example by setting the system date back.
--
Mike


You have to get the date and time from another computer that you can accept
as having the correct time. This could be a server, a database server or the
NIST server. As the applications I write connect to a database server it is
a trivial matter to get the date and time of the server via a stored
procedure. If you give more details about the application and what you are
trying to achieve then you might get a better answer .

SP
Jun 9 '06 #3
The date/time is taken from the real-time clock (RTC), if the user fakes the
system date, he effectively fakes the RTC.

Willy.

"Mike9900" <Mi******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
| How can I get the real system date/time if the user fakes the date, for
| example by setting the system date back.
|
|
| --
| Mike
Jun 9 '06 #4
Hello Mike9900,

I thing that using internet time servers like time.nist.gov or time.nist.gov
is more reliable way than rely on time in machine

M> How can I get the real system date/time if the user fakes the date,
M> for example by setting the system date back.
M>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jun 9 '06 #5
SP

"Mike9900" <Mi******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
How can I get the real system date/time if the user fakes the date, for
example by setting the system date back.


I just saw your other post asking about storing an expiration date time. I
gather you are trying to offer a trial version of your software and also
eliminate the possibility of uninstall / reinstall to "reset" the trial
period. This issue is a part of the whole software licensing issue. What
about the full blown product and the ability to install multiple times etc.
My suggestion is to look for a commercial product that has the features that
you want. VBox is one such product.

SP
Jun 9 '06 #6
Mike9900 wrote:
How can I get the real system date/time if the user fakes the date, for
example by setting the system date back.


If they have set the system date back, that becomes the new real system
date. It may not be the real date time, but it is as real as you can get on
that machine. So DateTime.Now will always give that value. If you need the
real date, not whatever date/time the user has set on their system, then you
need to query an external server that you trust to always be accurate.
--
Tom Porterfield

Jun 9 '06 #7
This is a C# utillity that uses SNTP to connect to remote time servers
and synchronize the system clock. The code is pretty straight forward
if I remember correctly. I recommend at least having a quick read over
the RFC (RFC 2030).

http://www.codeproject.com/cs/internet/ntpclient.asp

Cheers,

Russ

Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

DateTime.Now is the REAL time, real at least for the local computer.

You can check a time server in the internet ; I don't know if any right now
but I bet that a couple of US institutions give this service for free; and
if the returned time is different thatn the local time you change it.

Note that there will always be a little delta from the time the remote
server sent the time until you process it in your app.

You need to P/Invoke SetSystemTime from the win API

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mike9900" <Mi******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
How can I get the real system date/time if the user fakes the date, for
example by setting the system date back.
--
Mike


Jun 10 '06 #8
Thanks for the reply.

But I meant in the trial version of software the user could fake the date
and the program could run for ever. In MS Software, trial cannot be faked by
changing the system date.
--
Mike
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

DateTime.Now is the REAL time, real at least for the local computer.

You can check a time server in the internet ; I don't know if any right now
but I bet that a couple of US institutions give this service for free; and
if the returned time is different thatn the local time you change it.

Note that there will always be a little delta from the time the remote
server sent the time until you process it in your app.

You need to P/Invoke SetSystemTime from the win API

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mike9900" <Mi******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
How can I get the real system date/time if the user fakes the date, for
example by setting the system date back.
--
Mike


Jun 10 '06 #9
Mike9900 wrote:
How can I get the real system date/time if the user fakes the date, for
example by setting the system date back.


I see from the other posts you are talking about trail version software.
IMO, the only thing you can do is have the software "phone home" when
it starts. The first time it runs you record the date/time and user
key. At each startup you "phone home" to see if the software can still
run. After the trial period, that username/key can no longer be used.

Of course there is the issue of will your users accept your software
"phoning home" every time it starts up? I personally won't use software
like that. It all comes down to what you think your users will put up
with in a trial version.

There really is no way to prevent a determined user from running a trial
version multiple times. For example, if I _really_ wanted to run your
trail version without paying, I could use VMware or one of the other VM
apps to run your software and just keep resetting the virtual machine to
a state before expiration.

Have you thought about offering a reduced functionality version instead
of a timed version? All the cool features that someone will be willing
to pay for go in the full version. You give the users a sample with the
limited functionality version and not worry about trying to only allow
it to run for 30 days or 30 startups.

Jim
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
You roll an 18 in Dex and see if you
don't end up with a girlfriend
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
JimD
Central FL, USA, Earth, Sol
Jun 11 '06 #10
Sorry, missed that part. I wonder if they (MS) have a processes running
in the background to keep a running count since installation? What
about just limiting your trial to "uses" so each "day" is a day that
you open the app (although you could technically keep resetting the
clock to the same day and get away with it)?
Russ

Mike9900 wrote:
Thanks for the reply.

But I meant in the trial version of software the user could fake the date
and the program could run for ever. In MS Software, trial cannot be faked by
changing the system date.
--
Mike
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

DateTime.Now is the REAL time, real at least for the local computer.

You can check a time server in the internet ; I don't know if any right now
but I bet that a couple of US institutions give this service for free; and
if the returned time is different thatn the local time you change it.

Note that there will always be a little delta from the time the remote
server sent the time until you process it in your app.

You need to P/Invoke SetSystemTime from the win API

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mike9900" <Mi******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
How can I get the real system date/time if the user fakes the date, for
example by setting the system date back.
--
Mike



Jun 11 '06 #11
So, it will be like using number of Runs. Our currenct software is based on
number of runs.
--
Mike
"Dinsdale" wrote:
Sorry, missed that part. I wonder if they (MS) have a processes running
in the background to keep a running count since installation? What
about just limiting your trial to "uses" so each "day" is a day that
you open the app (although you could technically keep resetting the
clock to the same day and get away with it)?
Russ

Mike9900 wrote:
Thanks for the reply.

But I meant in the trial version of software the user could fake the date
and the program could run for ever. In MS Software, trial cannot be faked by
changing the system date.
--
Mike
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

DateTime.Now is the REAL time, real at least for the local computer.

You can check a time server in the internet ; I don't know if any right now
but I bet that a couple of US institutions give this service for free; and
if the returned time is different thatn the local time you change it.

Note that there will always be a little delta from the time the remote
server sent the time until you process it in your app.

You need to P/Invoke SetSystemTime from the win API

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mike9900" <Mi******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
> How can I get the real system date/time if the user fakes the date, for
> example by setting the system date back.
>
>
> --
> Mike


Jun 11 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: 3seas | last post by:
If you are not interested, then don't bitch, its a short message. http://www.matrixcommunity.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=8;t=000918 I don't know if that link got broken. -- 3...
1
by: Evan Smith | last post by:
My database is suffering from poor performance of late. Reports that used to run in a reasonable time, now take a while. The explain output show that the query is fully indexed, and the statistics...
6
by: Tony Liu | last post by:
Hi, when switched to the full screen mode in VS.NET IDE, is there any way to hide the main menu bar? Thanks Tony
1
by: Martin Platt | last post by:
Guys! I've been playing about with some code trying to get the satellite assembly resource files to work. From what I understand you must have a fallback for a particular language, as well as...
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
1
by: news.microsoft.com | last post by:
In vb.net, is there anyway to convert a SQL timestamp field into a real date. Also can I convert a real date into a SQL timestamp
15
by: Matt | last post by:
Hi There, Can anyone explain me the real advantages of (other than syntax) lambda expressions over anonymous delegates? advantage for one over the other. delegate int F(int a); F fLambda = a...
3
by: Mark Shroyer | last post by:
I guess this sort of falls under the "shameless plug" category, but here it is: Recently I used a custom metaclass in a Python program I've been working on, and I ended up doing a sort of write-up...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.