I'm trying to read the install date from WMI (Win32_OperatingSystem.InstallDate
). The return value looks like this: 20091020221246.000000+180. How can I get a valid Date?
Instead of parsing and extracting the values manually (how the accepted answer suggest), you can use the WbemScripting.SWbemDateTime
object.
check this sample
function WmiDateToTDatetime(vDate : OleVariant) : TDateTime;
var
FWbemDateObj : OleVariant;
begin;
FWbemDateObj := CreateOleObject('WbemScripting.SWbemDateTime');
FWbemDateObj.Value:=vDate;
Result:=FWbemDateObj.GetVarDate;
end;
For more info about this topic you can read this artile WMI Tasks using Delphi – Dates and Times
MagWMI from Magenta Systems contains MagWmiDate2DT() that does this.
http://www.magsys.co.uk/delphi/magwmi.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With