PC Review


Reply
Thread Tools Rate Thread

How to convert WinCE "FILETIME" to System.DateTime-format?

 
 
Danyel Meyer - dialog-it GmbH
Guest
Posts: n/a
 
      20th Feb 2004
Hallo!

Could anyone tell me how to convert a time given in a FILETIME structure
during P/Invoke to a DateTime value in VB.NET?
I´ve tried functions like DateTime.FromFileTime(), but what I get does not
match the time that should be it...

Many thanks in advance,

--
Danyel Meyer
-------------------------------------------
dialog-it GmbH
Röllinghäuser Strasse 55a
31061 Alfeld/Leine

Tel +49 (0) 5181 900 814
Fax +49 (0) 5181 900 815
E-Mail danyel.meyer <at> dialog-it.de


 
Reply With Quote
 
 
 
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      20th Feb 2004
Have you tried FromFileTimeUTC() which will convert a time expressed as
universal time (FromFileTime expects a FileTime expressed in the devices
currently set local time)

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

"Danyel Meyer - dialog-it GmbH dialog-it.de>" <info<at> wrote in message
news:%(E-Mail Removed)...
> Hallo!
>
> Could anyone tell me how to convert a time given in a FILETIME structure
> during P/Invoke to a DateTime value in VB.NET?
> I´ve tried functions like DateTime.FromFileTime(), but what I get does not
> match the time that should be it...
>
> Many thanks in advance,
>
> --
> Danyel Meyer
> -------------------------------------------
> dialog-it GmbH
> Röllinghäuser Strasse 55a
> 31061 Alfeld/Leine
>
> Tel +49 (0) 5181 900 814
> Fax +49 (0) 5181 900 815
> E-Mail danyel.meyer <at> dialog-it.de
>
>



 
Reply With Quote
 
Danyel Meyer - dialog-it GmbH
Guest
Posts: n/a
 
      20th Feb 2004
Hallo Peter,

Yes, I´ve already tried this, but it also gives a value that is hundreds of
years behind.
I´ve just tried to use coredll.dll´s FileTimeToSystemTime, because the WinCE
SYSTEMTIME structure looks more usable, but I get a NotSupportedException...

Hope anyone knows a way to get it done...


--
Danyel Meyer
-------------------------------------------
dialog-it GmbH
Röllinghäuser Strasse 55a
31061 Alfeld/Leine

Tel +49 (0) 5181 900 814
Fax +49 (0) 5181 900 815
E-Mail danyel.meyer <at> dialog-it.de

"Peter Foot [MVP]" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Have you tried FromFileTimeUTC() which will convert a time expressed as
> universal time (FromFileTime expects a FileTime expressed in the devices
> currently set local time)
>
> Peter
>
> --
> Peter Foot
> Windows Embedded MVP
> OpenNETCF.org Senior Advisor
> www.inthehand.com | www.opennetcf.org
>
> "Danyel Meyer - dialog-it GmbH dialog-it.de>" <info<at> wrote in message
> news:%(E-Mail Removed)...
> > Hallo!
> >
> > Could anyone tell me how to convert a time given in a FILETIME structure
> > during P/Invoke to a DateTime value in VB.NET?
> > I´ve tried functions like DateTime.FromFileTime(), but what I get does

not
> > match the time that should be it...
> >
> > Many thanks in advance,
> >
> > --
> > Danyel Meyer
> > -------------------------------------------
> > dialog-it GmbH
> > Röllinghäuser Strasse 55a
> > 31061 Alfeld/Leine
> >
> > Tel +49 (0) 5181 900 814
> > Fax +49 (0) 5181 900 815
> > E-Mail danyel.meyer <at> dialog-it.de
> >
> >

>
>



 
Reply With Quote
 
Danyel Meyer - dialog-it GmbH
Guest
Posts: n/a
 
      20th Feb 2004
Okay, it was ByVal where it should have been ByRef... works now, I think I
can use the SYSTEMTIME-structured format.


--
Danyel Meyer
-------------------------------------------
dialog-it GmbH
Röllinghäuser Strasse 55a
31061 Alfeld/Leine

Tel +49 (0) 5181 900 814
Fax +49 (0) 5181 900 815
E-Mail danyel.meyer <at> dialog-it.de

"Danyel Meyer - dialog-it GmbH dialog-it.de>" <info<at> schrieb im
Newsbeitrag news:O%(E-Mail Removed)...
> Hallo Peter,
>
> Yes, I´ve already tried this, but it also gives a value that is hundreds

of
> years behind.
> I´ve just tried to use coredll.dll´s FileTimeToSystemTime, because the

WinCE
> SYSTEMTIME structure looks more usable, but I get a

NotSupportedException...
>
> Hope anyone knows a way to get it done...
>
>
> --
> Danyel Meyer
> -------------------------------------------
> dialog-it GmbH
> Röllinghäuser Strasse 55a
> 31061 Alfeld/Leine
>
> Tel +49 (0) 5181 900 814
> Fax +49 (0) 5181 900 815
> E-Mail danyel.meyer <at> dialog-it.de
>
> "Peter Foot [MVP]" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:(E-Mail Removed)...
> > Have you tried FromFileTimeUTC() which will convert a time expressed as
> > universal time (FromFileTime expects a FileTime expressed in the devices
> > currently set local time)
> >
> > Peter
> >
> > --
> > Peter Foot
> > Windows Embedded MVP
> > OpenNETCF.org Senior Advisor
> > www.inthehand.com | www.opennetcf.org
> >
> > "Danyel Meyer - dialog-it GmbH dialog-it.de>" <info<at> wrote in message
> > news:%(E-Mail Removed)...
> > > Hallo!
> > >
> > > Could anyone tell me how to convert a time given in a FILETIME

structure
> > > during P/Invoke to a DateTime value in VB.NET?
> > > I´ve tried functions like DateTime.FromFileTime(), but what I get does

> not
> > > match the time that should be it...
> > >
> > > Many thanks in advance,
> > >
> > > --
> > > Danyel Meyer
> > > -------------------------------------------
> > > dialog-it GmbH
> > > Röllinghäuser Strasse 55a
> > > 31061 Alfeld/Leine
> > >
> > > Tel +49 (0) 5181 900 814
> > > Fax +49 (0) 5181 900 815
> > > E-Mail danyel.meyer <at> dialog-it.de
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      20th Feb 2004
struct FILETIME
{
int lo;
int hi;
}

FILETIME ft;
....
DateTime dt = DateTime.FromFileTimeUtc((((long)ft.hi) << 32) | ft.lo);

or in VB

Struct FileTime
Lo as Integer,
Hi as Integer
End Struct

Dim dt as DateTime = DateTime.FromFileTimeUtc( (CLng(ft.Hi) SHL 32) OR
ft.Lo)

"Danyel Meyer - dialog-it GmbH dialog-it.de>" <info<at> wrote in message
news:%(E-Mail Removed)...
> Hallo!
>
> Could anyone tell me how to convert a time given in a FILETIME structure
> during P/Invoke to a DateTime value in VB.NET?
> I´ve tried functions like DateTime.FromFileTime(), but what I get does not
> match the time that should be it...
>
> Many thanks in advance,
>
> --
> Danyel Meyer
> -------------------------------------------
> dialog-it GmbH
> Röllinghäuser Strasse 55a
> 31061 Alfeld/Leine
>
> Tel +49 (0) 5181 900 814
> Fax +49 (0) 5181 900 815
> E-Mail danyel.meyer <at> dialog-it.de
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert HD file system from "RAW" to "NTFS" on slave drive? (Win X =?Utf-8?B?RVhGRlBN?= Windows XP Help 1 6th Nov 2007 04:49 PM
Excel VBA to convert "dd.MM.yy" text to "dd/MM/yyyy" format date? =?Utf-8?B?UGF1bCBK?= Microsoft Excel Programming 4 11th Jul 2007 11:32 AM
Convert text "date" (DDMMMYY) to datetime value of YYYY-MM-DD - ho =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= Microsoft Excel Misc 7 29th Mar 2007 01:20 AM
Convert (managed) FILETIME to (unmanaged) FILETIME rob.zumwalt@gmail.com Microsoft C# .NET 5 5th Jan 2007 10:01 PM
Convert "Month" to "MonthName" format from db to PivotTable Billabong Microsoft Excel Programming 1 25th Aug 2004 09:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:25 AM.