Open With

closed account (Shp21hU5)
Hi guy’s can anyone help please.

I’m only an amateur programmer and I’ve created my own version of a notepad/text editor for my own use and even though it works fine there’s a facility I would like to add to it but don’t know how or where to start.

Before I any further may I just point out that I’m using Borland Builder c++ not Microsoft visual c++.

Anyway back to what I want my program to be able to do. When choosing the ‘Open With’ function and selecting my notepad I want it to be able to display the file, but at the moment it opens the program & displays a blank page because I don’t know how to get the files details and pass it to notepad.
Can anyone help please?
The files you open with a program are passed as arguments to the main function:
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <limits>

int main(int nargs, char const *const *args)
{
    for(int i = 0; i < nargs; ++i)
    {
        std::cout << i << " = " << args[i] << std::endl;
    }
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
Try compiling this to an exe and then drag one or more files onto the exe.
Last edited on
closed account (Shp21hU5)
Thank You L B ( 5588 )

I’ve compiled and tried your code it does exactly what I was trying to do, thank you !

I’m still not sure how to implement your code or adapt it in order for it to work with my Borland coding but at least now I’ve got something to work with. Once again thank you.
Topic archived. No new replies allowed.