How to programmatically change browser URL

Viewed 35

In my C++ Windows application I use ShellExecute to open a remote PDF file in the internet browser at a certain PDF Destination (dynamic bookmarks provided by Adobe Acrobat Reader):

ShellExecute(NULL, "open", "https://www.myweb.cloud/guide.pdf#dest_1", NULL , NULL, SW_SHOWNORMAL);

Then if I want to move to another Destination, another call to ShellExecute (with #dest_2 in the URL) simply open another page in the browser and download the PDF again opening it at that Destination.

Is there a way to programmatically change the URL (from #dest_1 to #dest_2) without making the browser to open a new page e re-dowload the PDF?

I also use LibCurl in my application in order to retrieve data from remote servers. Can I reach my goal with LibCurl? If so, could you plese show me a code sample?

Thanks in advance.

1 Answers
  1. External links opened with ShellExecute are always opened in a new tab by default. Chrome can't change this behavior. Early Firefox had an option for opening an external link in a currently active tab, but does not seem to have it now.
  2. You can download files with libcurl, see url2file example. After a file has been downloaded, you can open it in a certain application with ShellExecute. You just need to find an application, that is suitable to your requirements. For example Adobe Reader does not seem to support opening in the same tab 1, 2. As @KJ commented while I was typing my answer, sumatrapdf -reuse-instance seem to be suitable for you.
Related