Is there any API can I use with C++ to do this?
No, there is no API to perform this task.
Microsoft's policy is that such tasks must be performed by the user using the provided Windows GUI.