473,661 Members | 2,431 Online
Bytes | Software Development & Data Engineering Community
+ 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.dwHighDateTim e = 29698187 '(01C5288B to decimal)
a.dwLowDateTime = -539522172 '(??????? by 84 8B D7 DF)

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

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

Private Function GetFileToSystem Date(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_INFOR MATION

If FileTimeToSyste mTime(ft, st) Then

'retrieve the local time zone info
GetTimeZoneInfo rmation tz

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

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

If bIncludeTime Then

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

GetFileToSystem Date = buff

Else
GetFileToSystem Date = ""
End If

End Function
*************** *************** *************** ************
The vb6 code
Nov 21 '05 #1
2 9565
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.Curre ntUser
Reg =
Microsoft.Win32 .Registry.Local Machine.CreateS ubKey("System\C urrentControlSe t\Control\Windo ws")
Dim LSD As Byte() = DirectCast(Reg. GetValue("Shutd ownTime", ""), Byte())
Dim dt As DateTime
dt = dt.AddTicks(Bit Converter.ToInt 64(LSD, 0))
dt = dt.AddYears(160 0)
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.gbl...
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.Curre ntUser
Reg =
Microsoft.Win32 .Registry.Local Machine.CreateS ubKey("System\C urrentControlSe t\Control\Windo ws")
Dim LSD As Byte() = DirectCast(Reg. GetValue("Shutd ownTime", ""), Byte())
Dim dt As DateTime
dt = dt.AddTicks(Bit Converter.ToInt 64(LSD, 0))
dt = dt.AddYears(160 0)
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
2627
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 GetMethodParameter("GetStringValue") but can't find the method for binary, the MSDN documentation is terrible and doesn't provide a list of possible parameters. any ideas would be appreciated. thanks
19
4125
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
7
13073
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 a negative value. For example if I'm using the xd -c (Unix) on the file, I can see the value FFFFFFFFFFFFFFA2 which using the memcpy as described above I get -94. But the real value that I'd expect to get is a positive one.
8
10652
by: Saradhi | last post by:
Can any one put me a piece of code to write binary data into Registry?
5
5627
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 characters in character literal" Any thoughts?
3
4993
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
4861
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 case. The command returned some wierd characters.
2
4886
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
1551
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 without any success...... MemoryStream ms = new MemoryStream(Convert.FromBase64String((String)ControlPropertyTable));
0
8343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8758
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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 we have to send another system
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.