?
Solved

SystemTimeToFileTime fails every time

Posted on 1999-01-04
2
Medium Priority
?
911 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 140 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

770 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