Solved

SystemTimeToFileTime fails every time

Posted on 1999-01-04
2
893 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 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