How do you open a path in explorer by code in c++. I googled and couldn’t find any thing but systems commands to do this, however, i dont want it to block or show the console window.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You probably are looking for the
ShellExecute()function inshellapi.h. It is called with an "action verb", a path, and optional parameters. In your case this will want either "open" or "explore" as follows:This will open an unattached explorer window at C:. ShellExecute() will give basically the same action as typing in a command at the Run dialog. It will also handle URLs, so the following will open up the user’s default browser:
Although make sure to pay attention to the note in the documentation that ShellExecute relies on COM (Although your code doesn’t have to worry about any COM objects itself).