Dynamic Invoke of Sysmon.OCX Member "AddCounter" via reflection/interop failsXPathNavigator - how do

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,<br/>
<br/>
running this code to set a property on the hosted Sysmon.ocx ActiveX control and calling a parameterless method works fine:<br/>
<br/>
<pre lang="x-c# using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Reflection;


namespace TestApplication
{
public partial class Form1 : Form
{
private AxHostingControl axHost;
private object ocxObject;

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
ocxObject.GetType().InvokeMember("DisplayProperties", BindingFlags.InvokeMethod, null, ocxObject, null);
}

private void Form1_Load(object sender, EventArgs e)
{
Application.OleRequired();
this.axHost = new AxHostingControl(Type.GetTypeFromProgID("Sysmon",true).GUID.ToString());
this.Controls.Add(this.axHost);
this.ocxObject = axHost.GetOcx();
}

private void button2_Click(object sender, EventArgs e)
{
ocxObject.GetType().InvokeMember("ShowToolbar", BindingFlags.SetProperty, null, ocxObject, new object[] { false });
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
this.axHost.Dispose();
}

private void button3_Click(object sender, EventArgs e)
{
object[] Parameters = new object[2];
Parameters[0] = "\Process(*)\% Processor Time";
Parameters[1] = new object();

try
{
ocxObject.GetType().InvokeMember("AddCounter", BindingFlags.InvokeMethod, null, ocxObject, Parameters);
}
catch (Exception err)
{
if (err.InnerException is COMException)
{
MessageBox.Show((err.InnerException as COMException).Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error


Hi all;
How can I determine if when Im using XPathNavigator.MoveToFirstChild/MoveToNext if I am on an element that has text, but no children <nodes>? The call XPathNavigator.HasChildren is true because the text for that node is a child.
??? - thanks - dave <hr class="sig http://www.huffingtonpost.com/david-thielen/the-programming-olympics_b_972273.html The Programming Olympics - Code Wars

View the full article
 
Back
Top