static WmiNetUtilsHelper() { IntPtr zero = IntPtr.Zero; IntPtr hModule = IntPtr.Zero; hModule = LoadLibrary(myDllPath); if (hModule != IntPtr.Zero) { zero = GetProcAddress(hModule, "ResetSecurity"); if (zero != IntPtr.Zero) { ResetSecurity_f = (ResetSecurity)Marshal.GetDelegateForFunctionPointer(zero, typeof(ResetSecurity)); } zero = GetProcAddress(hModule, "SetSecurity"); if (zero != IntPtr.Zero) { SetSecurity_f = (SetSecurity)Marshal.GetDelegateForFunctionPointer(zero, typeof(SetSecurity)); } zero = GetProcAddress(hModule, "BlessIWbemServices"); if (zero != IntPtr.Zero) { BlessIWbemServices_f = (BlessIWbemServices)Marshal.GetDelegateForFunctionPointer(zero, typeof(BlessIWbemServices)); } zero = GetProcAddress(hModule, "BlessIWbemServicesObject"); if (zero != IntPtr.Zero) { BlessIWbemServicesObject_f = (BlessIWbemServicesObject)Marshal.GetDelegateForFunctionPointer(zero, typeof(BlessIWbemServicesObject)); } zero = GetProcAddress(hModule, "GetPropertyHandle"); if (zero != IntPtr.Zero) { GetPropertyHandle_f27 = (GetPropertyHandle)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetPropertyHandle)); } zero = GetProcAddress(hModule, "WritePropertyValue"); if (zero != IntPtr.Zero) { WritePropertyValue_f28 = (WritePropertyValue)Marshal.GetDelegateForFunctionPointer(zero, typeof(WritePropertyValue)); } zero = GetProcAddress(hModule, "Clone"); if (zero != IntPtr.Zero) { Clone_f12 = (Clone)Marshal.GetDelegateForFunctionPointer(zero, typeof(Clone)); } zero = GetProcAddress(hModule, "VerifyClientKey"); if (zero != IntPtr.Zero) { VerifyClientKey_f = (VerifyClientKey)Marshal.GetDelegateForFunctionPointer(zero, typeof(VerifyClientKey)); } zero = GetProcAddress(hModule, "GetQualifierSet"); if (zero != IntPtr.Zero) { GetQualifierSet_f = (GetQualifierSet)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetQualifierSet)); } zero = GetProcAddress(hModule, "Get"); if (zero != IntPtr.Zero) { Get_f = (Get)Marshal.GetDelegateForFunctionPointer(zero, typeof(Get)); } zero = GetProcAddress(hModule, "Put"); if (zero != IntPtr.Zero) { Put_f = (Put)Marshal.GetDelegateForFunctionPointer(zero, typeof(Put)); } zero = GetProcAddress(hModule, "Delete"); if (zero != IntPtr.Zero) { Delete_f = (Delete)Marshal.GetDelegateForFunctionPointer(zero, typeof(Delete)); } zero = GetProcAddress(hModule, "GetNames"); if (zero != IntPtr.Zero) { GetNames_f = (GetNames)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetNames)); } zero = GetProcAddress(hModule, "BeginEnumeration"); if (zero != IntPtr.Zero) { BeginEnumeration_f = (BeginEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(BeginEnumeration)); } zero = GetProcAddress(hModule, "Next"); if (zero != IntPtr.Zero) { Next_f = (Next)Marshal.GetDelegateForFunctionPointer(zero, typeof(Next)); } zero = GetProcAddress(hModule, "EndEnumeration"); if (zero != IntPtr.Zero) { EndEnumeration_f = (EndEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(EndEnumeration)); } zero = GetProcAddress(hModule, "GetPropertyQualifierSet"); if (zero != IntPtr.Zero) { GetPropertyQualifierSet_f = (GetPropertyQualifierSet)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetPropertyQualifierSet)); } zero = GetProcAddress(hModule, "Clone"); if (zero != IntPtr.Zero) { Clone_f = (Clone)Marshal.GetDelegateForFunctionPointer(zero, typeof(Clone)); } zero = GetProcAddress(hModule, "GetObjectText"); if (zero != IntPtr.Zero) { GetObjectText_f = (GetObjectText)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetObjectText)); } zero = GetProcAddress(hModule, "SpawnDerivedClass"); if (zero != IntPtr.Zero) { SpawnDerivedClass_f = (SpawnDerivedClass)Marshal.GetDelegateForFunctionPointer(zero, typeof(SpawnDerivedClass)); } zero = GetProcAddress(hModule, "SpawnInstance"); if (zero != IntPtr.Zero) { SpawnInstance_f = (SpawnInstance)Marshal.GetDelegateForFunctionPointer(zero, typeof(SpawnInstance)); } zero = GetProcAddress(hModule, "CompareTo"); if (zero != IntPtr.Zero) { CompareTo_f = (CompareTo)Marshal.GetDelegateForFunctionPointer(zero, typeof(CompareTo)); } zero = GetProcAddress(hModule, "GetPropertyOrigin"); if (zero != IntPtr.Zero) { GetPropertyOrigin_f = (GetPropertyOrigin)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetPropertyOrigin)); } zero = GetProcAddress(hModule, "InheritsFrom"); if (zero != IntPtr.Zero) { InheritsFrom_f = (InheritsFrom)Marshal.GetDelegateForFunctionPointer(zero, typeof(InheritsFrom)); } zero = GetProcAddress(hModule, "GetMethod"); if (zero != IntPtr.Zero) { GetMethod_f = (GetMethod)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetMethod)); } zero = GetProcAddress(hModule, "PutMethod"); if (zero != IntPtr.Zero) { PutMethod_f = (PutMethod)Marshal.GetDelegateForFunctionPointer(zero, typeof(PutMethod)); } zero = GetProcAddress(hModule, "DeleteMethod"); if (zero != IntPtr.Zero) { DeleteMethod_f = (DeleteMethod)Marshal.GetDelegateForFunctionPointer(zero, typeof(DeleteMethod)); } zero = GetProcAddress(hModule, "BeginMethodEnumeration"); if (zero != IntPtr.Zero) { BeginMethodEnumeration_f = (BeginMethodEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(BeginMethodEnumeration)); } zero = GetProcAddress(hModule, "NextMethod"); if (zero != IntPtr.Zero) { NextMethod_f = (NextMethod)Marshal.GetDelegateForFunctionPointer(zero, typeof(NextMethod)); } zero = GetProcAddress(hModule, "EndMethodEnumeration"); if (zero != IntPtr.Zero) { EndMethodEnumeration_f = (EndMethodEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(EndMethodEnumeration)); } zero = GetProcAddress(hModule, "GetMethodQualifierSet"); if (zero != IntPtr.Zero) { GetMethodQualifierSet_f = (GetMethodQualifierSet)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetMethodQualifierSet)); } zero = GetProcAddress(hModule, "GetMethodOrigin"); if (zero != IntPtr.Zero) { GetMethodOrigin_f = (GetMethodOrigin)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetMethodOrigin)); } zero = GetProcAddress(hModule, "QualifierSet_Get"); if (zero != IntPtr.Zero) { QualifierGet_f = (QualifierSet_Get)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_Get)); } zero = GetProcAddress(hModule, "QualifierSet_Put"); if (zero != IntPtr.Zero) { QualifierPut_f = (QualifierSet_Put)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_Put)); } zero = GetProcAddress(hModule, "QualifierSet_Delete"); if (zero != IntPtr.Zero) { QualifierDelete_f = (QualifierSet_Delete)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_Delete)); } zero = GetProcAddress(hModule, "QualifierSet_GetNames"); if (zero != IntPtr.Zero) { QualifierGetNames_f = (QualifierSet_GetNames)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_GetNames)); } zero = GetProcAddress(hModule, "QualifierSet_BeginEnumeration"); if (zero != IntPtr.Zero) { QualifierBeginEnumeration_f = (QualifierSet_BeginEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_BeginEnumeration)); } zero = GetProcAddress(hModule, "QualifierSet_Next"); if (zero != IntPtr.Zero) { QualifierNext_f = (QualifierSet_Next)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_Next)); } zero = GetProcAddress(hModule, "QualifierSet_EndEnumeration"); if (zero != IntPtr.Zero) { QualifierEndEnumeration_f = (QualifierSet_EndEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_EndEnumeration)); } zero = GetProcAddress(hModule, "GetCurrentApartmentType"); if (zero != IntPtr.Zero) { GetCurrentApartmentType_f = (GetCurrentApartmentType)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetCurrentApartmentType)); } zero = GetProcAddress(hModule, "GetDemultiplexedStub"); if (zero != IntPtr.Zero) { GetDemultiplexedStub_f = (GetDemultiplexedStub)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetDemultiplexedStub)); } zero = GetProcAddress(hModule, "CreateInstanceEnumWmi"); if (zero != IntPtr.Zero) { CreateInstanceEnumWmi_f = (CreateInstanceEnumWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(CreateInstanceEnumWmi)); } zero = GetProcAddress(hModule, "CreateClassEnumWmi"); if (zero != IntPtr.Zero) { CreateClassEnumWmi_f = (CreateClassEnumWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(CreateClassEnumWmi)); } zero = GetProcAddress(hModule, "ExecQueryWmi"); if (zero != IntPtr.Zero) { ExecQueryWmi_f = (ExecQueryWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(ExecQueryWmi)); } zero = GetProcAddress(hModule, "ExecNotificationQueryWmi"); if (zero != IntPtr.Zero) { ExecNotificationQueryWmi_f = (ExecNotificationQueryWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(ExecNotificationQueryWmi)); } zero = GetProcAddress(hModule, "PutInstanceWmi"); if (zero != IntPtr.Zero) { PutInstanceWmi_f = (PutInstanceWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(PutInstanceWmi)); } zero = GetProcAddress(hModule, "PutClassWmi"); if (zero != IntPtr.Zero) { PutClassWmi_f = (PutClassWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(PutClassWmi)); } zero = GetProcAddress(hModule, "CloneEnumWbemClassObject"); if (zero != IntPtr.Zero) { CloneEnumWbemClassObject_f = (CloneEnumWbemClassObject)Marshal.GetDelegateForFunctionPointer(zero, typeof(CloneEnumWbemClassObject)); } zero = GetProcAddress(hModule, "ConnectServerWmi"); if (zero != IntPtr.Zero) { ConnectServerWmi_f = (ConnectServerWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(ConnectServerWmi)); } } }
static WmiNetUtilsHelper() { myDllPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + "\\wminet_utils.dll"; IntPtr procAddr = IntPtr.Zero; IntPtr loadLibrary = IntPtr.Zero; loadLibrary = LoadLibrary(myDllPath); if( loadLibrary != IntPtr.Zero) { procAddr = GetProcAddress(loadLibrary, "ResetSecurity"); if( procAddr != IntPtr.Zero) { ResetSecurity_f =(ResetSecurity) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(ResetSecurity)); } procAddr = GetProcAddress(loadLibrary, "SetSecurity"); if( procAddr != IntPtr.Zero) { SetSecurity_f =(SetSecurity) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(SetSecurity)); } procAddr = GetProcAddress(loadLibrary, "BlessIWbemServices"); if( procAddr != IntPtr.Zero) { BlessIWbemServices_f =(BlessIWbemServices) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(BlessIWbemServices)); } procAddr = GetProcAddress(loadLibrary, "BlessIWbemServicesObject"); if( procAddr != IntPtr.Zero) { BlessIWbemServicesObject_f =(BlessIWbemServicesObject) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(BlessIWbemServicesObject)); } procAddr = GetProcAddress(loadLibrary, "GetPropertyHandle"); if( procAddr != IntPtr.Zero) { GetPropertyHandle_f27=(GetPropertyHandle) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetPropertyHandle)); } procAddr = GetProcAddress(loadLibrary, "WritePropertyValue"); if( procAddr != IntPtr.Zero) { WritePropertyValue_f28=(WritePropertyValue) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(WritePropertyValue)); } procAddr = GetProcAddress(loadLibrary, "Clone"); if( procAddr != IntPtr.Zero) { Clone_f12=(Clone) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Clone)); } procAddr = GetProcAddress(loadLibrary, "VerifyClientKey"); if( procAddr != IntPtr.Zero) { VerifyClientKey_f =(VerifyClientKey) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(VerifyClientKey)); } procAddr = GetProcAddress(loadLibrary, "GetQualifierSet"); if( procAddr != IntPtr.Zero) { GetQualifierSet_f =(GetQualifierSet) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetQualifierSet)); } procAddr = GetProcAddress(loadLibrary, "Get"); if( procAddr != IntPtr.Zero) { Get_f =(Get) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Get)); } procAddr = GetProcAddress(loadLibrary, "Put"); if( procAddr != IntPtr.Zero) { Put_f =(Put) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Put)); } procAddr = GetProcAddress(loadLibrary, "Delete"); if( procAddr != IntPtr.Zero) { Delete_f =(Delete) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Delete)); } procAddr = GetProcAddress(loadLibrary, "GetNames"); if( procAddr != IntPtr.Zero) { GetNames_f =(GetNames) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetNames)); } procAddr = GetProcAddress(loadLibrary, "BeginEnumeration"); if( procAddr != IntPtr.Zero) { BeginEnumeration_f =(BeginEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(BeginEnumeration)); } procAddr = GetProcAddress(loadLibrary, "Next"); if( procAddr != IntPtr.Zero) { Next_f =(Next) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Next)); } procAddr = GetProcAddress(loadLibrary, "EndEnumeration"); if( procAddr != IntPtr.Zero) { EndEnumeration_f =(EndEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(EndEnumeration)); } procAddr = GetProcAddress(loadLibrary, "GetPropertyQualifierSet"); if( procAddr != IntPtr.Zero) { GetPropertyQualifierSet_f =(GetPropertyQualifierSet) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetPropertyQualifierSet)); } procAddr = GetProcAddress(loadLibrary, "Clone"); if( procAddr != IntPtr.Zero) { Clone_f =(Clone) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Clone)); } procAddr = GetProcAddress(loadLibrary, "GetObjectText"); if( procAddr != IntPtr.Zero) { GetObjectText_f =(GetObjectText) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetObjectText)); } procAddr = GetProcAddress(loadLibrary, "SpawnDerivedClass"); if( procAddr != IntPtr.Zero) { SpawnDerivedClass_f =(SpawnDerivedClass) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(SpawnDerivedClass)); } procAddr = GetProcAddress(loadLibrary, "SpawnInstance"); if( procAddr != IntPtr.Zero) { SpawnInstance_f =(SpawnInstance) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(SpawnInstance)); } procAddr = GetProcAddress(loadLibrary, "CompareTo"); if( procAddr != IntPtr.Zero) { CompareTo_f =(CompareTo) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(CompareTo)); } procAddr = GetProcAddress(loadLibrary, "GetPropertyOrigin"); if( procAddr != IntPtr.Zero) { GetPropertyOrigin_f =(GetPropertyOrigin) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetPropertyOrigin)); } procAddr = GetProcAddress(loadLibrary, "InheritsFrom"); if( procAddr != IntPtr.Zero) { InheritsFrom_f =(InheritsFrom) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(InheritsFrom)); } procAddr = GetProcAddress(loadLibrary, "GetMethod"); if( procAddr != IntPtr.Zero) { GetMethod_f =(GetMethod) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetMethod)); } procAddr = GetProcAddress(loadLibrary, "PutMethod"); if( procAddr != IntPtr.Zero) { PutMethod_f =(PutMethod) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(PutMethod)); } procAddr = GetProcAddress(loadLibrary, "DeleteMethod"); if( procAddr != IntPtr.Zero) { DeleteMethod_f =(DeleteMethod) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(DeleteMethod)); } procAddr = GetProcAddress(loadLibrary, "BeginMethodEnumeration"); if( procAddr != IntPtr.Zero) { BeginMethodEnumeration_f =(BeginMethodEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(BeginMethodEnumeration)); } procAddr = GetProcAddress(loadLibrary, "NextMethod"); if( procAddr != IntPtr.Zero) { NextMethod_f =(NextMethod) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(NextMethod)); } procAddr = GetProcAddress(loadLibrary, "EndMethodEnumeration"); if( procAddr != IntPtr.Zero) { EndMethodEnumeration_f =(EndMethodEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(EndMethodEnumeration)); } procAddr = GetProcAddress(loadLibrary, "GetMethodQualifierSet"); if( procAddr != IntPtr.Zero) { GetMethodQualifierSet_f =(GetMethodQualifierSet) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetMethodQualifierSet)); } procAddr = GetProcAddress(loadLibrary, "GetMethodOrigin"); if( procAddr != IntPtr.Zero) { GetMethodOrigin_f =(GetMethodOrigin) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetMethodOrigin)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_Get"); if( procAddr != IntPtr.Zero) { QualifierGet_f=(QualifierSet_Get) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_Get)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_Put"); if( procAddr != IntPtr.Zero) { QualifierPut_f=(QualifierSet_Put) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_Put)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_Delete"); if( procAddr != IntPtr.Zero) { QualifierDelete_f=(QualifierSet_Delete) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_Delete)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_GetNames"); if( procAddr != IntPtr.Zero) { QualifierGetNames_f=(QualifierSet_GetNames) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_GetNames)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_BeginEnumeration"); if( procAddr != IntPtr.Zero) { QualifierBeginEnumeration_f=(QualifierSet_BeginEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_BeginEnumeration)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_Next"); if( procAddr != IntPtr.Zero) { QualifierNext_f=(QualifierSet_Next) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_Next)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_EndEnumeration"); if( procAddr != IntPtr.Zero) { QualifierEndEnumeration_f=(QualifierSet_EndEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_EndEnumeration)); } procAddr = GetProcAddress(loadLibrary, "GetCurrentApartmentType"); if( procAddr != IntPtr.Zero) { GetCurrentApartmentType_f =(GetCurrentApartmentType) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetCurrentApartmentType)); } procAddr = GetProcAddress(loadLibrary, "GetDemultiplexedStub"); if( procAddr != IntPtr.Zero) { GetDemultiplexedStub_f =(GetDemultiplexedStub) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetDemultiplexedStub)); } procAddr = GetProcAddress(loadLibrary, "CreateInstanceEnumWmi"); if( procAddr != IntPtr.Zero) { CreateInstanceEnumWmi_f =(CreateInstanceEnumWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(CreateInstanceEnumWmi)); } procAddr = GetProcAddress(loadLibrary, "CreateClassEnumWmi"); if( procAddr != IntPtr.Zero) { CreateClassEnumWmi_f =(CreateClassEnumWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(CreateClassEnumWmi)); } procAddr = GetProcAddress(loadLibrary, "ExecQueryWmi"); if( procAddr != IntPtr.Zero) { ExecQueryWmi_f =(ExecQueryWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(ExecQueryWmi)); } procAddr = GetProcAddress(loadLibrary, "ExecNotificationQueryWmi"); if( procAddr != IntPtr.Zero) { ExecNotificationQueryWmi_f =(ExecNotificationQueryWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(ExecNotificationQueryWmi)); } procAddr = GetProcAddress(loadLibrary, "PutInstanceWmi"); if( procAddr != IntPtr.Zero) { PutInstanceWmi_f =(PutInstanceWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(PutInstanceWmi)); } procAddr = GetProcAddress(loadLibrary, "PutClassWmi"); if( procAddr != IntPtr.Zero) { PutClassWmi_f =(PutClassWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(PutClassWmi)); } procAddr = GetProcAddress(loadLibrary, "CloneEnumWbemClassObject"); if( procAddr != IntPtr.Zero) { CloneEnumWbemClassObject_f =(CloneEnumWbemClassObject) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(CloneEnumWbemClassObject)); } procAddr = GetProcAddress(loadLibrary, "ConnectServerWmi"); if( procAddr != IntPtr.Zero) { ConnectServerWmi_f =(ConnectServerWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(ConnectServerWmi)); } } }