If your PC is connected to the Internet you can use Atomic Clocks to synchronise your PC's clock for free!
For System Administrators this can be great on your file servers.
Every 24 hours (if you leave the program running) it will re-synchronise your clock, so make sure you have an Internet connection that hangs up automatically if you pay call charges.
The Windows executable file and the C++ source code as an MSVC++ Project are available as well as just the C++ header file.
The code for this involves dealing with Locales and Time Zones...
It's written using MFC and Windows Sockets, but you don't need to create a [New][Project][MFC Appwizard(exe)] and opt to include support for Windows Sockets.
The support for Sockets is part of the class and allows you to use the class in a separate Thread.
To use the idea generally, use the class CAtomic...
The Atomic clocks it attempts to read are from a list of SNTP sites found on the Internet by searching for "SNTP Site List"
You should do the same and choose sites that are close to you for fastest response time.
It starts at the top of the list and if it can't get a connection and time, it tries the next in the list.
In your Dialog Header file:
In your .cpp file:
Synch can have the parameter
Synch(false) which stops it from changing your system clock.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(1419) Last modified: Fri, 15 May 2009 15:24:19 +0100