Thread: windows date...

  1. #1

    windows date...

    ok heres what i want to do

    1). get the date from windows (lol the little thing when you click it it brings up a clock) (how?)
    2). store that date (should be easy)
    3). change the date to a date i specify (how?)

    the rest i think i can figure on my own but this little part is a tad confusing for me... i have only done dos programs before :|

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    Well, if you don't need the windows specific stuff, why not using the old DOS functions ? strdate will give you the date and strtime will give you the time. You can store them where you would like to store them. File, RAM, wherever.

    For changing you will have to look up windows specific routines.

    Which would be using a SYSTEMTIME structure and GetSystemTime and SetSystemTime.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    well i have the rest of my program done and the only thing i need now are three functions

    1). one to get the current month and day and store it anywhere :|

    2). a second change the date to april 1

    3). a third one to change the date back to the original date...

    ive read up on the SYSTEMTIME structure and GetSystemTime and SetSystemTime and have gotten pretty damn confused im new to the whole api thing and when i try to implement any of thses i get some odd 75 errors soi donno maybe if someone has any example source for any function that uses SYSTEMTIME structure and GetSystemTime and SetSystemTime it would be much apreciated!

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Here's somthing for you to play with...

    #include <windows.h>
    #include <iostream>
    using namespace std;
    #include <cstdlib>
    void SetTime(LPSYSTEMTIME lpst){
    void GetTime(LPSYSTEMTIME lpst){
    	cout << "Date " << lpst->wDay << "/" << lpst->wMonth;
    	cout << "/" << lpst->wYear << endl;
    int main(int argc,char* argv){
    	char ch;
    	SYSTEMTIME stold,stset;
    	GetTime(&stold);//get time and display
    	memcpy(&stset,&stold,sizeof(SYSTEMTIME));//copy current time
    	stset.wDay = 1;//set to 1st day
    	stset.wMonth = 4;//set to April
    	SetTime(&stset);//set to new date
    	cout << "Date changed. Have a look!" << endl;
    	cout << "Press enter twice to revert to real date" << endl;
    	cin.get(ch);//wait for enter
    	SetTime(&stold);//set date back
    	cout << "Date reset.";
    	return 0;

    Oh...compile as a c++ console application

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get and set windows time and date
    By huwan in forum Windows Programming
    Replies: 18
    Last Post: 05-13-2008, 10:33 AM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM