Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Azure opening pdf ShellExecute


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Last Post: Oct 19, 2016 9:15 PM Last Post By: Andrew McIsaac
Andrew McIsaac

Posts: 93
Registered: 3/12/13
Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 16, 2016 1:42 PM
Good afternoon,

Using Windows 10, XE8 C++ Enterprise,

I have a program that can read a database from Azure, which is working well.
I would like to add the capability of being able to open a pdf from the "cloud".
I am trying to open using ShellExecute :

On local machine :
ShellExecute(0, 0, L"[FULL DIR]
[pdf name.pdf]", 0, 0 , SW_SHOW ); // this works well,

but when I try to open from Azure, I get a can't find error when trying :

ShellExecute(0, 0, L"https://[azure user name].file.core.windows.net/[DIR]/[pdf name.pdf]", 0, 0 , SW_SHOW );
this DIR is the URL provided by MS Azure.

I'm sure it has something to do with login and password.
Anyone know how to add that to the ShellExecute Command ?

Thanks in Advance.
Andrew
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2016 3:31 PM   in response to: Andrew McIsaac in response to: Andrew McIsaac
Andrew wrote:

I'm sure it has something to do with login and password. Anyone know
how to add that to the ShellExecute Command ?

ShellExecute() will detect a URL and simply launch the user's default web
brower with the URL. So any problems you are having are going to be with
your web browser, not with ShellExecute() itself.

If you need to include login credentials in the URL, you can use this syntax
for that:

"https://<username>[:<password>]@<hostname>[:<port>][/<path to filename>]"


For example:

"https://joe:smoe@azureusername.file.core.windows.net/share/file.pdf"


--
Remy Lebeau (TeamB)
Andrew McIsaac

Posts: 93
Registered: 3/12/13
Re: Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2016 8:38 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you for the reply,

When using ShellExecute with local :
ShellExecute(0, 0, L"E:
Users
Andrew
Documents
IDM_C
Programs
Tests
Open PDF
GAMA.pdf", 0, 0 , SW_SHOW ); // opens pdf ; all works well

But for the Azure :
Tryng :

ShellExecute(0, 0, L"[login ID]:[password]:[full path]", 0, 0 , SW_SHOW );

and Full Path = Copied from Azure URL Edit Box. with file name https://[my user name].file.core.windows.net/idmc/Logo.JPG

Still no go?

Thanks,
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2016 12:01 PM   in response to: Andrew McIsaac in response to: Andrew McIsaac
Andrew wrote:

ShellExecute(0, 0, L"[login ID]:[password]:[full path]", 0, 0 , SW_SHOW );

You have to provide a full and valid URL. The login username/password are
part of the URL data, not a prefix to it. Look at my earlier example again
more carefully:

"https://<username>[:<password>]@<hostname>[:<port>][/<path to filename>]"


For example:

ShellExecute(0, 0, L"https://[loginID]:[password]@[azure user name].file.core.windows.net/idmc/Logo.JPG", 
0, 0, SW_SHOW);


If ShellExecute() does not see a URL scheme at the beginning of the string,
it will not launch the user's web browser.

--
Remy Lebeau (TeamB)
Andrew McIsaac

Posts: 93
Registered: 3/12/13
Re: Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2016 7:06 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thanks for helping,
My Azure user login has a @gmail.com in the "User Login",
Could that be contributing to the failure as ...]:[password]@[azure user name].... is separated by @ ?

ShellExecute(0, 0, L"https://myemail at gmail dot com":password at myaccountname dot file dot core dot windows dot net/idmc/Logo.JPG",0, 0, SW_SHOW);

Thanks,

Andrew McIsaac

Posts: 93
Registered: 3/12/13
Re: Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2016 7:09 PM   in response to: Andrew McIsaac in response to: Andrew McIsaac
Symbols were replaced when posted @ and .

ShellExecute(0, 0, L"https://myemail at gmail dot com":password at myaccountname dot file dot core dot windows dot net/idmc/Logo.JPG",0, 0, SW_SHOW);

Thanks,

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2016 11:32 AM   in response to: Andrew McIsaac in response to: Andrew McIsaac
Andrew wrote:

My Azure user login has a @gmail.com in the "User Login",

Since "@" is reserved for separating user info from hostname, it will have
to be url-encoded as "%40" in your login name, eg:

ShellExecute(0, 0, L"https://myemail%40gmail.com:password@myaccountname.file.core.windows.net/idmc/Logo.JPG", 
0, 0, SW_SHOW);


--
Remy Lebeau (TeamB)
Andrew McIsaac

Posts: 93
Registered: 3/12/13
Re: Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2016 4:48 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thanks,
I had tried that, I also have a ! in password so I use the %21....

Still no dice.

There must be some other permission setting that I cant get past...

Thanks,
Andrew
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2016 5:37 PM   in response to: Andrew McIsaac in response to: Andrew McIsaac
Andrew wrote:

I had tried that, I also have a ! in password so I use
the %21....
Still no dice.

There must be some other permission setting that I
cant get past...

If you enter just the URL into the Start Menu's "Run" field, does it open
the remote PDF file? "Run" does the same thing that ShellExecute/Ex() does
(in fact, it likely just calls ShellExecute/Ex() directly).

Otherwise, use something like TIdHTTP or URLDownloadToFile() to manually
download the PDF to a temp local file, and then ShellExecute() that file.

--
Remy Lebeau (TeamB)
Andrew McIsaac

Posts: 93
Registered: 3/12/13
Re: Azure opening pdf ShellExecute  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2016 9:15 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thanks for the help so far,

Did not want to save file first as the target for this application is mobile devices, with limited storage, and a potential of a large number of documents to be viewed.

Thanks,
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02