Solved

SystemTimeToFileTime fails every time

Posted on 1999-01-04
2
877 Views
Last Modified: 2008-03-17
Hi, everyone,

I'm writing a Windows CE app and the following code, which is really simple, fails every time. All I'm trying to do is convert a SYSTEMTIME structure to a FILETIME.

SYSTEMTIME st;
FILETIME ft;

st.wYear = (WORD)Year;
st.wMonth = (WORD)Month;
st.wDay = (WORD)Day;
st.wHour = (WORD)0;
st.wMinute = (WORD)0;
st.wSecond = (WORD)0;
st.wMilliseconds = (WORD)0;

// convert to something readable
SystemTimeToFileTime(&st, &ft);

The error code is 1413 (Invalid index). What the @@#@# does Invalid index have to do with anything ??

Please help.
0
Comment
Question by:ssite
2 Comments
 
LVL 4

Expert Comment

by:nil_dib
ID: 1181477
Which CE version dod you use (2.0/2.1/2.11)?
I tried the same and it works (SystemTimeToFileTime returns 0).
Does the code only fail on the emulation?

0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 70 total points
ID: 1181478
Hi.
I think, you must make GetLastError only if function
SystemTimeToFileTime fails!
Example:
  SYSTEMTIME st;
  FILETIME ft;
 
  GetSystemTime(&st);

// convert to something readable
  memset(&ft, 0, sizeof(ft));
  st.wYear = 1;//error!
  if (SystemTimeToFileTime(&st, &ft) == 0)
    {
      DWORD nError = GetLastError();
    }
If function not fail, GetLastError can return something old
(not linked with last current operation)!
Of couse, you must work in Win32 application.
Regards, Alex
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now