Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i ma wittting program for Win32_NTLogEvent..when i use time generated property in it. it runs but gives me wrong output..

My code is as below

C++
    hres = pclsObj->Get(L"TimeWritten", 0, &vtProp, 0, 0);
    wcout << "Event Log time written : " << vtProp.date << endl << endl ;

hres = pclsObj->Get(L"TimeGenerated", 0, &vtProp1, 0, 0);
    wcout << "Event Log time generated : " << vtProp1.date << endl << endl ;

and i got output as

Event Log time written -9.25596e+061

Event Log time generated -9.25596e+061

which is not in date/time format
Posted
Updated 3-Apr-14 20:18pm
v2

1 solution

 
Share this answer
 
v4
Comments
Member 10678759 4-Apr-14 9:00am    
hi i try to use how u suggest me

Date date;

vtProp.vt=VT_DATE;

vtProp.date=date;

VariantChangeType(&vtProp,&vtProp,VARIANT_NOVALUEPROP,VT_BSTR);

hres = pclsObj->Get(L"TimeWritten", 0, &vtProp, 0, 0);

wcout << "Event Log date generated : " << vtProp.bstrVal << endl;

now output is 20140403105831..i think its date but still not in format
[no name] 4-Apr-14 9:24am    
So from the first link the format is yyyymmddHHMMSS.mmmmmmsUUU which is 2014-04-03 10:58:31 etc. You have to parse it yourself or use SWbemDateTime which is all in the links I posted in the answer. It is all there you just have to read the documentation provided.
Member 10678759 7-Apr-14 5:55am    
i pasrse it wid mid function..thanx a lot its working..:-D
[no name] 7-Apr-14 6:00am    
Thanks - I have posted a tip on how to do this - see link above
CPallini 7-Apr-14 6:02am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900