Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

swagg

Small C/C++ IDE and how to open a folder?

12 posts in this topic

I recently upgraded to windows 10 with a clean install, and had to re-install all my drivers. My keyboard got macro keys that you can assign to different things. In the old keyboard software I could assign my macro keys to "open an application", and could assign paths to folders, which was incredible efficient to organize things.

 

However, in this new keyboard software version, I'm not allowed to open folders; only .exe files. I've contacted the company support about this, but as usual you don't get any help. So for me to be able to open folders with my macro keys again I'll be required to code one .exe file for each folder I'd want to assign to my macro key.

 

Now, I've never coded in C or C++ before, so I'm completely lost. First thing is obviously getting an IDE, preferably something small and compact as I don't need any fancy features, I just wanna compile my code. I looked around a few IDE's. I installed one really old and small IDE that wasn't even functional, I then googled for some more IDE's and found visual studio and noticed that eclipse had an IDE for C++. Now the problem with these two is that visual studio is really big and would probably take me 10 hours ish to download, and I'm using eclipse for java, I wouldn't want to mess that up by downloading eclipse for C++.

 

Secondly I'm lost on how I'd even code this, or how to code in C++ at all.

Out from googling, I'm assuming I'd need something like this if the folder I'd like to open would be "E:\Library files\Downloads"

#include <stdlib.h>int main() {ShellExecute(handle, "open", "E:\Library files\Downloads", NULL, NULL, SW_SHOWMAXIMIZED);return 0;}

However I have no idea at all.

 

Tl;dr:

1. What's a small C/C++ IDE, other than eclipse and visual studio?

2. What would the complete code (I don't wanna leech but idk this stuff lol) be to open a folder with spaces in its path? (such as "E:\Library files\Downloads")

 

Thanks in advance for any help :)

Share this post


Link to post
Share on other sites

Ditch netbeans and download clion

Netbeans gave me strange errors, so will do haha, thanks for the suggestion :P

 

Too bad it's paid, but the 30 day trial should be well more than enough to make these simple programs

Share this post


Link to post
Share on other sites

Did you get this figured out?

Yes, I coded the programs in java then used a .jar > .exe convert program suggested by tacomanstan :D

Share this post


Link to post
Share on other sites

Be a real man and use vim + command line. ;)
 
For paths with a space, all you have to do is put an escape character before the space (for windows it's ^ see here). i.e.
 
"E:\Library files\Downloads" would be "E:\Library^ files\Downloads"

 

Also you might want to look into command line arguments. So you can essentially do (from the command line):

 

myProgram.exe E:\Library^ files\Downloads

 

which would open the path you specify in the argument of the program. Obviously you can't run the program from the command line via a macro, but I'm sure there's a way to specify default command line options for the exe (probably in the properties of the exe somewhere). Code to do this would be pretty much:

 

BTW. If the command line args work, then instead of making a program to do this, you could probably just make a shortcut to explorer and modify it's properties to open up a folder of your choice (via command line arguments). 

Edited by this_is_my_username

Share this post


Link to post
Share on other sites

It seems that you actually want to "explore" (which is just executing Windows Explorer, lol). C++ code would be pretty much like this:

#include <iostream>int main(int argc, char* argv[]){    if(argc == 1)    {        std::cerr << "pls specify a path to open\n";        return 1;    }    // assume the first arg is the path to open    const char* pathToOpen = argv[1];    // open it via ShellExecute    int nRet = (int)ShellExecute(NULL, "explore", pathToOpen, NULL, SW_SHOWNORMAL);    // not sure if this works    // source: http://www.experts-exchange.com/articles/1595/Execute-a-Program-with-C.html    if (nRet <= 32)     {        DWORD dw = GetLastError();         char szMsg[250];        FormatMessage(                FORMAT_MESSAGE_FROM_SYSTEM,	                0, dw, 0,                szMsg, sizeof(szMsg),                NULL                 );        MessageBox(szMsg, "Error launching Calculator");    }}

Btw in case you're wondering why I don't have return 0 at the bottom: http://stackoverflow.com/a/18402896/1427533.

 

Also, you would have to include header(s) for ShellExecute, MessageBox, DWORD, etc. I'm not sure what this header is in windows, maybe it's windows.h? I don't know. I don't use Windows ;p. As I said, it's probably easier to make a shortcut of explorer.exe and change it's properties to open up a specific folder.

Share this post


Link to post
Share on other sites

It seems that you actually want to "explore" (which is just executing Windows Explorer, lol). C++ code would be pretty much like this:

#include <iostream>int main(int argc, char* argv[]){    if(argc == 1)    {        std::cerr << "pls specify a path to open\n";        return 1;    }    // assume the first arg is the path to open    const char* pathToOpen = argv[1];    // open it via ShellExecute    int nRet = (int)ShellExecute(NULL, "explore", pathToOpen, NULL, SW_SHOWNORMAL);    // not sure if this works    // source: http://www.experts-exchange.com/articles/1595/Execute-a-Program-with-C.html    if (nRet <= 32)     {        DWORD dw = GetLastError();         char szMsg[250];        FormatMessage(                FORMAT_MESSAGE_FROM_SYSTEM,	                0, dw, 0,                szMsg, sizeof(szMsg),                NULL                 );        MessageBox(szMsg, "Error launching Calculator");    }}

Btw in case you're wondering why I don't have return 0 at the bottom: http://stackoverflow.com/a/18402896/1427533.

 

Also, you would have to include header(s) for ShellExecute, MessageBox, DWORD, etc. I'm not sure what this header is in windows, maybe it's windows.h? I don't know. I don't use Windows ;p. As I said, it's probably easier to make a shortcut of explorer.exe and change it's properties to open up a specific folder.

Thank you very much for the help, but I already have what I want :P

 

The code might not be optimal, but it works perfectly

 

Thanks though :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.