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;
}
}