[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 946
  • Last Modified:

SystemTimeToFileTime fails every time

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
ssite
Asked:
ssite
1 Solution
 
nil_dibCommented:
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
 
AlexVirochovskyCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now