Question

am trying to create a project that create a file, formatting it, create a new partition and mount it, dismount it ... in C++ with Qtcretor I found that winapi offer several function help me to do that Format method of the Win32_Volume class and AddMountPoint method of the Win32_Volume class but there is no code example show how to use it I try with WMI C++ Application Examples but in vain

can any one put me on the way please?

Any help will be appreciated and thanks in advance.

Was it helpful?

Solution

Using WMI should be done in Powershell scripts, not C++.

If you're already lost at the beginning, then just limit the use of C++ to CreateProcess() function call with the reference to some Powershell script.

If you insist on writing everything in C++, then the MSDN docs should help you to use the WMI's COM API. There are samples of C++ code. What you call "winapi classes" are really the COM interfaces with all the complications. I think you won't get away by just copy'n'pasting some lines, since COM is not as intuitive as VBScript.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top