Click here to Skip to main content
15,891,777 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Strange bug in SetPixel in Visual C++ program running under Windows Vista: only displaying if (x&256)==0 Pin
Joao Araujo21-Nov-09 12:47
Joao Araujo21-Nov-09 12:47 
GeneralDetect USB Masstorage device Pin
Xeqtr20-Apr-08 4:08
Xeqtr20-Apr-08 4:08 
GeneralCompiling hello world app Pin
Saturday3AM19-Apr-08 22:19
Saturday3AM19-Apr-08 22:19 
GeneralRe: Compiling hello world app Pin
CPallini19-Apr-08 22:50
mveCPallini19-Apr-08 22:50 
GeneralRe: Compiling hello world app Pin
Saturday3AM19-Apr-08 23:04
Saturday3AM19-Apr-08 23:04 
GeneralRe: Compiling hello world app Pin
CPallini19-Apr-08 23:10
mveCPallini19-Apr-08 23:10 
GeneralRe: Compiling hello world app Pin
Saturday3AM19-Apr-08 23:16
Saturday3AM19-Apr-08 23:16 
GeneralFile listings in Windows seem to ignore Daylight Savings Pin
2b|!2b==?19-Apr-08 22:05
2b|!2b==?19-Apr-08 22:05 
I am on the west coast of the US, so my time zone is Pacific Time.

Depending on whether I am using a Win2K or WinXP machine, I share or don't share the TZ with Tijuana, Mexico.

I created the following console program

//*****************************************************************************
FILETIME Increment(FILETIME ft, const unsigned long long inc)
{
ULARGE_INTEGER uliTime;
uliTime.LowPart = ft.dwLowDateTime;
uliTime.HighPart = ft.dwHighDateTime;
uliTime.QuadPart += inc;
ft.dwLowDateTime = uliTime.LowPart;
ft.dwHighDateTime = uliTime.HighPart;
return ft;
}

//*****************************************************************************
int _tmain(int argc, _TCHAR * argv[])
{
static const unsigned long long OneThousand = 1000ll;
static const unsigned long long OneSecond = OneThousand * OneThousand * 10ll; // 1000 milliseconds per second * 1000 microseconds per millisecond
static const unsigned long long OneDay = 24 * 60 * 60 * OneSecond;

char Name[45];

SYSTEMTIME sysCreationTime = { 0 };
SYSTEMTIME sysLastAccessTime = { 0 };
SYSTEMTIME sysLastWriteTime = { 0 };

sysCreationTime.wYear = 2007;
sysCreationTime.wMonth = 1;
sysCreationTime.wDayOfWeek = 4;
sysCreationTime.wDay = 11;
sysCreationTime.wHour = 12;
sysCreationTime.wMinute = 0;
sysCreationTime.wSecond = 0;
sysCreationTime.wMilliseconds = 0;

sysLastAccessTime = sysCreationTime;
sysLastWriteTime = sysCreationTime;

sysLastAccessTime.wHour = 1;
sysLastWriteTime.wHour = 2;

FILETIME fileCreationTime;
FILETIME fileLastAccessTime;
FILETIME fileLastWriteTime;

::SystemTimeToFileTime(&sysCreationTime, &fileCreationTime);
::SystemTimeToFileTime(&sysLastAccessTime, &fileLastAccessTime);
::SystemTimeToFileTime(&sysLastWriteTime, &fileLastWriteTime);

fileCreationTime = Increment(fileCreationTime, 480ll * 60ll * OneSecond); // Pacific Std Time is 480 minutes less than UTC. UTC = local time + bias
fileLastAccessTime = Increment(fileLastAccessTime, 480ll * 60ll * OneSecond);
fileLastWriteTime = Increment(fileLastWriteTime, 480ll * 60ll * OneSecond);

for(int i = 0; i < 365; ++i) {

sprintf(Name, "%03d", i);

HANDLE f = ::CreateFile(Name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(f == INVALID_HANDLE_VALUE) {
::fprintf(stderr, "Error CreateFile\n");
} else {

if( ! ::SetFileTime(f, &fileCreationTime, &fileLastAccessTime, &fileLastWriteTime)) {
::fprintf(stderr, "Error SetFileTime\n");
}

fileCreationTime = Increment(fileCreationTime, OneDay);
fileLastAccessTime = Increment(fileLastAccessTime, OneDay);
fileLastWriteTime = Increment(fileLastWriteTime, OneDay);

::CloseHandle(f);
}
}

return 0;
}

Windows Explorer and a console 'dir' both report modified file times of 3 am for all 365 files. This surprises me. I expect a file with a date set 24 hours later than another file, going across when time changed from std time to dst, would be one hour different than the other file. And all files within the DST time period would be an hour different from files outside the DST time period, since every file is set to 24 hrs later then the previous. But all files have the same time!(?)

I must be doing something wrong, but I can't see what is the problem.

Any ideas?

Thanks
Rogue
GeneralUpgrading from VC Studio 6.0 Pin
Member 26088019-Apr-08 16:21
Member 26088019-Apr-08 16:21 
GeneralRe: Upgrading from VC Studio 6.0 Pin
Hamid_RT19-Apr-08 18:00
Hamid_RT19-Apr-08 18:00 
GeneralRe: Upgrading from VC Studio 6.0 Pin
CPallini19-Apr-08 23:06
mveCPallini19-Apr-08 23:06 
GeneralRe: Upgrading from VC Studio 6.0 Pin
Kevin McFarlane20-Apr-08 7:15
Kevin McFarlane20-Apr-08 7:15 
GeneralRe: Upgrading from VC Studio 6.0 Pin
Joe Woodbury20-Apr-08 17:31
professionalJoe Woodbury20-Apr-08 17:31 
GeneralMS access (ODBC)in Dialog based application Pin
elegantcharm19-Apr-08 12:57
elegantcharm19-Apr-08 12:57 
GeneralRe: MS access (ODBC)in Dialog based application Pin
Hamid_RT19-Apr-08 18:11
Hamid_RT19-Apr-08 18:11 
GeneralRe: MS access (ODBC)in Dialog based application Pin
Joseph Marzbani20-Apr-08 6:34
Joseph Marzbani20-Apr-08 6:34 
GeneralRe: MS access (ODBC)in Dialog based application Pin
Hamid_RT20-Apr-08 8:53
Hamid_RT20-Apr-08 8:53 
QuestionHow to use related path in #pragma comment(lib,"...") Pin
includeh1019-Apr-08 12:50
includeh1019-Apr-08 12:50 
QuestionHow to save sound from microphone and video from web camera to one stream? Pin
Member 412458119-Apr-08 10:36
Member 412458119-Apr-08 10:36 
GeneralRe: How to save sound from microphone and video from web camera to one stream? Pin
Hamid_RT19-Apr-08 18:07
Hamid_RT19-Apr-08 18:07 
Questionmultithreaded programming on multicore systems Pin
e_yp19-Apr-08 1:11
e_yp19-Apr-08 1:11 
GeneralRe: multithreaded programming on multicore systems Pin
Gary R. Wheeler19-Apr-08 1:52
Gary R. Wheeler19-Apr-08 1:52 
GeneralRe: multithreaded programming on multicore systems Pin
CPallini19-Apr-08 2:25
mveCPallini19-Apr-08 2:25 
QuestionHow to Compare two different date format Pin
sharanu18-Apr-08 22:55
sharanu18-Apr-08 22:55 
AnswerRe: How to Compare two different date format Pin
Gary R. Wheeler19-Apr-08 1:07
Gary R. Wheeler19-Apr-08 1:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.