Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:57:59+00:00 2026-06-17T18:57:59+00:00

How do I get the return value of the Format method of the Win32_Volume

  • 0

How do I get the return value of the Format method of the Win32_Volume class ?

I use: public void ManagementObject.InvokeMethod(ManagementOperationObserver watcher, string methodName, Object[] args) that in System.Management, and it has void return signature.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:58:00+00:00Added an answer on June 17, 2026 at 6:58 pm

    To get the result directly you can use the ManagementObject.InvokeMethod Method (String, ManagementBaseObject, InvokeMethodOptions) version of the InvokeMethod Method.

    Like so

    using System;
    using System.Collections.Generic;
    using System.Management;
    using System.Text;
    
    namespace GetWMI_Info
    {
        class Program
        {
    // This method is used to format the volume.
    
            static void Main(string[] args)
            {
                try
                {
                    ManagementScope Scope;                
                    Scope = new ManagementScope("\\\\.\\root\\CIMV2", null);
    
                    Scope.Connect();
                    ObjectGetOptions Options      = new ObjectGetOptions();
                    ManagementPath Path           = new ManagementPath("Win32_Volume.DeviceID=\"\\\\\\\\?\\\\Volume{178edf63-2039-11e2-8012-005056c00008}\\\\\"");
                    ManagementObject ClassInstance= new ManagementObject(Scope, Path, Options);
                    ManagementBaseObject inParams = ClassInstance.GetMethodParameters("Format");
    
    
                    ManagementBaseObject outParams= ClassInstance.InvokeMethod("Format", inParams ,null);
                    Console.WriteLine("{0,-35} {1,-40}","Return Value",outParams["ReturnValue"]);
    
                }
                catch (Exception e)
                {
                    Console.WriteLine(String.Format("Exception {0} Trace {1}",e.Message,e.StackTrace));
                }
                Console.WriteLine("Press Enter to exit");
                Console.Read();
            }
        }
    }
    

    Now if you are using a ManagementOperationObserver for asynchronous execution, you can get the result in the ObjectReady event

    Like so

    using System;
    using System.Collections.Generic;
    using System.Management;
    using System.Text;
    
    namespace GetWMI_Info
    {
        public class InvokeAsync
        {
            public InvokeAsync()
            {
    
                // Create a results watcher object,
                ManagementOperationObserver results = new ManagementOperationObserver();
    
                // Attach handler to events for results and completion
                results.ObjectReady += new ObjectReadyEventHandler(this.NewObject);
                results.Completed += new CompletedEventHandler(this.Done);
    
                ManagementScope Scope;
                Scope = new ManagementScope("\\\\.\\root\\CIMV2", null);
    
                Scope.Connect();
                ObjectGetOptions Options = new ObjectGetOptions();
                ManagementPath Path = new ManagementPath("Win32_Volume.DeviceID=\"\\\\\\\\?\\\\Volume{178edf63-2039-11e2-8012-005056c00008}\\\\\"");
                ManagementObject ClassInstance = new ManagementObject(Scope, Path, Options);
                ManagementBaseObject inParams = ClassInstance.GetMethodParameters("Format");
    
    
                ClassInstance.InvokeMethod(results, "Format", inParams, null);
    
                while (!this.Completed)
                {
                    System.Threading.Thread.Sleep(1000);
                }
    
                this.Reset();
    
            }
    
            private bool isCompleted = false;
    
            private void NewObject(object sender,
                ObjectReadyEventArgs obj)
            {
                Console.WriteLine("ReturnValue : {0}", obj.NewObject["ReturnValue"]);
            }
    
            private bool Completed
            {
                get
                {
                    return isCompleted;
                }
            }
    
            private void Reset()
            {
                isCompleted = false;
            }
    
            private void Done(object sender,
                CompletedEventArgs obj)
            {
                isCompleted = true;
            }
    
            public static void Main()
            {
                InvokeAsync example =
                    new InvokeAsync();
    
                return;
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my controller: @RequestMapping(value = /, method = RequestMethod.GET) public String index() { return
How to make web service methods return string value in lines format? My web
I have this simplified method: private string GetStringValue(object Value) { return ((double)Value).ToString(); } which
When call WinExec to run a .exe, I get return value 0x21. According to
How can I get the return value of a process? Basically I'm ** ShellExecute
Is it possible to get a return value other than error level from .net
I am trying to do 2 things: get a return value from a C
Is it possible to get the 'nth' return value from a function without having
Possible Duplicate: Return value from thread I want to get the free memory of
I am using PHP and I return this value: $_SESSION['sessionNum'] and I get an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.