Solved

SystemTimeToFileTime fails every time

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 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…

706 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

14 Experts available now in Live!

Get 1:1 Help Now