Exemplo n.º 1
0
        public static MiResult GetNamespace(Microsoft.Management.Infrastructure.Native.InstanceHandle instanceHandle, out string str2)
        {
            IntPtr            ptr      = instanceHandle.DangerousGetHandle();
            NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance>(ptr);

            str2 = instance.Namespace;
            return(MiResult.OK);
        }
Exemplo n.º 2
0
        public static MiResult SetServerName(Microsoft.Management.Infrastructure.Native.InstanceHandle handle, string serverName)
        {
            IntPtr            ptr      = handle.DangerousGetHandle();
            NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance>(ptr);

            instance.ServerName = serverName;
            return(MiResult.OK);
        }
Exemplo n.º 3
0
        public static MiResult GetClass(Microsoft.Management.Infrastructure.Native.InstanceHandle instanceHandle, out ClassHandle classHandle)
        {
            MiResult          result   = MiResult.OK;
            IntPtr            ptr      = instanceHandle.DangerousGetHandle();
            NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (ptr);

            classHandle = null;
            if (!string.IsNullOrEmpty(instance.ClassName))
            {
                var options  = CimNativeApi.GetDestinationOptions(new SessionHandle(instance.SessionHandle));
                var classObj = CimNativeApi.QueryClasses(options, instance.Namespace, CimNativeApi.WQLNamespace, "SELECT * FROM Meta_Class WHERE ClassName = '" + instance.ClassName + "'").FirstOrDefault();
                classObj.SessionHandle = instance.SessionHandle;
                IntPtr classPtr = CimNativeApi.MarshalledObject.Create <NativeCimClass>(classObj);
                classHandle = new ClassHandle(classPtr, true);
            }
            return(result);
        }