views:

50

answers:

1

As part of a WMI Coupled provider that I'm creating I need to write an instance enumerator. The code I have is below. What I need to do is get the Class instance associated with the process. Any ideas?

    static public WMIProviderSample GetInstance([ManagementName("ID")] int processId)
    {
        try
        {
            Process[] processes = Process.GetProcessesByName("WMI Provider Sample");
            foreach (Process process in processes)
            {
                if (process.Id == processId)
                {
                    // Need to convert the process to an instance of WMIProviderSampel
                }
            }

            return null;
        }
        catch (ArgumentException)
        {
            return null;
        }
    }
A: 

It is a Windows Forms Class that I created using the Visual Studio 2008 WinForm Wizard. I'm modifying it to become a WMI Managed class according to the article http://msdn.microsoft.com/en-us/library/cc268228.aspx

John P. Grieb
The provider from that article is a .dll hosted by wmiprvse.exe. Could you provide more details on the structure of your provider?
Uros Calakovic

related questions