Dasser Basyouni Dasser Basyouni - 1 year ago 85
C++ Question

open .rar with exe and extract it

enter image description here
I want to create a C++ code that extracts the .rar with the

system("unrar e c:\myFiles.rar");

for example

but how can I get the name and the path of the .rar if I opened it with the exe that have the system code

As the photo i need to open the apk/zip/rar with the exe I made and want the exe to detect the path and the name of the apk/rar/zip needed to be extracted

Answer Source

You need to register your exe in the Windows Registry as being able to handle apk/zip/rar files:

File Types and File Associations

How to Register a File Type for a New Application

For example:

        (Default) = "RarFile"

                    (Default) = ""C:\Path to\myapp.exe" "%1""

Then, when a user clicks on such a file in Windows Explorer, it can run your exe, and you can use the argv parameter of main() to detect the filename, eg:

#include <string>

int main(int argc, char* argv[])
    if (argc > 1)
        std::string cmd = std::string("unrar e ") + argv[1];
    return 0;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download