Page 1 of 1

Convert registry REG_BINARY DriverDate to PB Date?

Posted: Wed Jan 25, 2006 11:38 pm
by techjunkie
Hi!

I have looked at MSDN but can't find an explanation for the

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-[x]\[Printer Driver Name]\DriverDate

REG_BINARY format.

Does anyone know how this can be converted to PB Date Format?

Cheers!

Posted: Thu Jan 26, 2006 5:13 am
by Sparkie
Assume the variable regValue holds the value you received from the registry.

Code: Select all

fTime.FILETIME
sTime.SYSTEMTIME

; --> Here's the REG_BINARY value for my printer driver date
;     as it appears in my registry   00 c0 9f eb c5 28 c4 01
;     The result should be 2004.04.23

dtLow = $EB9FC000
dtHigh = $01C428C5

;     Comment out the previous 2 lines and uncomment the next
;     2 lines to use the REB_BINARY value you receive from your
;     RegQueryValueEx_() where regValue holds the binary date data.

;dtLow = PeekL(@regValue)
;dtHigh = PeekL(@regValue+4)

fTime\dwLowDateTime = dtLow
fTime\dwHighDateTime = dtHigh
FileTimeToSystemTime_(fTime, @sTime)
pbDate = Date(sTime\wYear, sTime\wMonth, sTime\wDay, sTime\wHour, sTime\wMinute, sTime\wSecond)
pbDate$ = FormatDate("%yyyy.%mm.%dd", pbDate)
MessageRequester("Binary date converted", pbDate$)
End

Posted: Thu Jan 26, 2006 10:33 am
by techjunkie
Sparkie wrote:Assume the variable regValue holds the value you received from the registry.
Thanks a lot Sparkie!! :D

A handy routine to have in the library... :!:

Thanks again!

Posted: Thu Feb 02, 2006 9:12 pm
by techjunkie
Hmmm... Is it possible to do the same with,

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-[x]\[Printer Driver Name]\DriverVersion

Can't find any Interface for "Version Info".

Posted: Fri Feb 03, 2006 12:19 am
by Sparkie
See if this works for you. It's all guesswork but it returns the correct info for my driver version. ;)

Code: Select all

verMajor = PeekW(@regBinaryValue+6)
verMinor = PeekW(@regBinaryValue+4)
verRev =  PeekW(@regBinaryValue+2)
verBuild = PeekW(@regBinaryValue)
ver$ = Str(verMajor) + "." + Str(verMinor) + "." + Str(verRev) + "." + Str(verBuild)
MessageRequester("DriverVersion", ver$)

Posted: Fri Feb 03, 2006 12:47 am
by techjunkie
Sparkie! If you ever visit Sweden or Denmark, I'll buy you a beer or two... :D

You are a real Windows Guru! Thanks!!!!

Posted: Fri Feb 03, 2006 4:37 am
by Sparkie
You're welcome techjunkie, and thank you for the kind words...

and for the offer to pay my way over to Sweden (I don't mind flying coach)...

and for promising to buy me a brewery of my very own (You'll be hired as my senior taste tester). 8) :P :wink: :)