Invoking a method thtough C#

643 views Asked by At

I am trying to get some data from the UWF_Volume WMI provider. Please see the following link,

https://msdn.microsoft.com/en-us/library/jj979756(v=winembedded.81).aspx

More specifically I am trying to get the exclusion files using the following class,

UInt32 GetExclusions([out, EmbeddedInstance("UWF_ExcludedFile")] string ExcludedFiles[]);

I am not familiar with out parameters but from a research I can understand that acts as a reference argument. So I wrote the following method,

public void getUWFExclusions()
    {
        {
            string computer = ".";

            ManagementScope scope = new ManagementScope(@"\\" + computer + @"\root\standardcimv2\embedded");

            ManagementClass cls = new ManagementClass(scope.Path.Path, "UWF_Volume", null);


            foreach (MethodData m in cls.Methods)

            {
                richTextBox1.AppendText("The class contains this method:" + m.Name + "\n");
            }

            ManagementBaseObject outParams;

            foreach (ManagementObject mo in cls.GetInstances())
            {
                outParams = mo.InvokeMethod("GetExclusions", null, null);
                richtextbox1.appendtext(string.format("ExcludedFiles" + mo[ExcludedFiles]));
            }

        }

        catch (Exception e)
        {
            richTextBox1.AppendText(e.ToString());
        }

    }

The problem is that the line,

                richtextbox1.appendtext(string.format("ExcludedFiles" + mo[ExcludedFiles]));

returns "Not Found"

I appreciate any help to debug this problem.

1

There are 1 answers

0
atp9 On

I guess you are missing the Object Query that actually gets data via call to WMI. I am not sure about windows 8 but till 7 we used to get data by WQL and that is not there in above code.