How to read Event Viewer Information from Code Unit

ckndr47
Member Posts: 100
Hello Everybody,
I have to read messages of EventViewer from my code unit; I dont have any ocx for that;
Please guide me in this regard. I have to complete that task in a very short time. So kindly help me out.
Thanks in Advance
I have to read messages of EventViewer from my code unit; I dont have any ocx for that;
Please guide me in this regard. I have to complete that task in a very short time. So kindly help me out.
Thanks in Advance
0
Comments
-
Use WMI Querys. WMI can be easily developed by using the WMITools provided by Microsoft: http://www.microsoft.com/downloads/details.aspx?FamilyID=6430f853-1120-48db-8cc5-f2abdc3ed314&DisplayLang=en
With the WMI CMI Studio you can create your SQL String, to get all Event Descriptions from one Application for example.
Because I used the WMI Automation Server only in a Delphi Applications I cannot give you some Navision examples. But I think you must create some Automation Variables of the Type Microsoft WMI Scripting V1.2 Library and the needed Subtypes Locator, Services and Object Set.
Maybe this Code Snippet could be helpful. I queries all events of the given Service.VAR aLoc : ISWbemLocator; aSrv : ISWbemServices; aObjSet : ISWbemObjectSet; pEnum : IEnumvarIANT; aLoc := CoSWbemLocator.Create; aSrv := aLoc.ConnectServer(cConfig.sWMI_Host,'', cConfig.sWMI_User,cConfig.GetWMIPassword(),'','',0, nil); aSrv.Security_.ImpersonationLevel := wbemImpersonationLevelImpersonate; aObjSet := aSrv.ExecQuery('SELECT EventType, Message, TimeGenerated, InsertionStrings FROM Win32_NTLogEvent WHERE Logfile="Application" AND SourceName="<Service Name>", 'WQL', wbemFlagReturnImmediately + wbemFlagForwardOnly, nil); pEnum := aObjSet.Get__NewEnum as IEnumvarIANT;
The enumeration contains the Response, but I don't know how to handle this in Navision? Be careful that for WMI Querys on localhost any User and Password should be given if you have administrative rights.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions