473,462 Members | 1,243 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Convert 8 bytes binary value to date in registry

yxq
There are 8 bytes binary value stored date and time in Registry.
84 8B D7 DF 8B 28 C5 01

I want to convert the binary value to date using VB.NET.

Dim a As FILETIME
a.dwHighDateTime = 29698187 '(01C5288B to decimal)
a.dwLowDateTime = -539522172 '(??????? by 84 8B D7 DF)

MsgBox (GetFileToSystemDate(a, False))
http://vbnet.mvps.org/index.html?cod...stshutdown.htm

*****************************************
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Private Function GetFileToSystemDate(ft As FILETIME, _
Optional bIncludeTime As Boolean =
False) As String

Dim buff As String
Dim st As SYSTEMTIME 'system (UNC) time
Dim lt As SYSTEMTIME 'local time
Dim tz As TIME_ZONE_INFORMATION

If FileTimeToSystemTime(ft, st) Then

'retrieve the local time zone info
GetTimeZoneInformation tz

'convert the system time returned above
'to a local time taking the time zone
'info into account
SystemTimeToTzSpecificLocalTime tz, st, lt

'now just write it out
buff = Format$(DateSerial(lt.wYear, lt.wMonth, lt.wDay), "Long Date")

If bIncludeTime Then

buff = buff & " @ " & Format$(TimeSerial(lt.wHour, _
lt.wMinute, _
lt.wSecond), _
"Long Time")
End If

GetFileToSystemDate = buff

Else
GetFileToSystemDate = ""
End If

End Function
************************************************** *******
The vb6 code
Nov 21 '05 #1
2 9541
yxq,

I was curious if I could get this with normal Net instructions. I thought I
succeeded.

Can you try it?

\\\
Dim Reg As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.CurrentUser
Reg =
Microsoft.Win32.Registry.LocalMachine.CreateSubKey ("System\CurrentControlSet\Control\Windows")
Dim LSD As Byte() = DirectCast(Reg.GetValue("ShutdownTime", ""), Byte())
Dim dt As DateTime
dt = dt.AddTicks(BitConverter.ToInt64(LSD, 0))
dt = dt.AddYears(1600)
dt = dt.ToLocalTime
MessageBox.Show(dt.ToString)
///

I hope this helps?

Cor
Nov 21 '05 #2
yxq
Yes, you are right!

Thank you very much
"Cor Ligthert" <no************@planet.nl> дÈëÏûÏ¢ÐÂÎÅ:%2****************@TK2MSFTNGP10.phx.g bl...
yxq,

I was curious if I could get this with normal Net instructions. I thought
I succeeded.

Can you try it?

\\\
Dim Reg As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.CurrentUser
Reg =
Microsoft.Win32.Registry.LocalMachine.CreateSubKey ("System\CurrentControlSet\Control\Windows")
Dim LSD As Byte() = DirectCast(Reg.GetValue("ShutdownTime", ""), Byte())
Dim dt As DateTime
dt = dt.AddTicks(BitConverter.ToInt64(LSD, 0))
dt = dt.AddYears(1600)
dt = dt.ToLocalTime
MessageBox.Show(dt.ToString)
///

I hope this helps?

Cor

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lastusernameleft | last post by:
What is the easiest .net method to read a REG_BINARY value from the registry? I'm using a ManagementClass from the System.Management namespace and can retrieve string values using...
19
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
7
by: Golan | last post by:
Hi, I need to convert a Binary value to Decimal. I've been told that the value is an unsigned one. How can I do this? I use memcpy into an unsigned char variable, but when I print the value I got...
8
by: Saradhi | last post by:
Can any one put me a piece of code to write binary data into Registry?
5
by: Max Adams | last post by:
How can I set a byte to hold the binary value 10? Doing this doesn't work, I want to store the code for 10 in 1 byte of memory. byte encodedBytes = '10'; Doesn't compile "Too many...
3
by: ForestDemon | last post by:
i'm able to use the GetValue() function for string usage/manipulation, but i can't figure out how to read/write a binary value to/from a key. any help is greatly appreciated...thanks folks!
3
by: tfeller | last post by:
I would like to drop the leading 0x on a binary value so I can do a bitwise operation. Here is simplified code: select right(0x88186000,8) I expected to get back 88186000, this was not the...
2
by: Navneet Kumar | last post by:
hi friends please help me to have a small piece of code that can convert a binary value to its 2's compliment .
0
by: jcarter | last post by:
How can I create a CodeDOM statement to accomplish the following this.pictureBox.Image = <Convert the binary value of the picture from the XML file and display> I have tried the following...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.