ok so i have used ShellExecute() before but with a specific value eg. "http://www.facebook.com" but now i want this program to be more flexible and allow the user to put the website he wants to.
Ok.
As you're using a std::string to store your URL and ShellExecute is expecting a pointer to a C style string (LPCSTR) as a parameter, you simply need to change your ShellExecute call to:
The c_str() function of the standard library std::string class returns the contents of the string as a C style string...Which is exactly what ShellExecute is expecting as a parameter. That should fix your problem!
Cheers for now,
Jas.
Last edited by JasonHippy; Sep 21st, 2009 at 10:55 am.
Ooops, I didn't notice that at the bottom of the post!
Hmm..It's been quite a while since I did any .NET stuff with C++.
I can't find any of my old managed code, but I know I've had to do similar conversions in the past. I think this may've been one of the ways I've used....
// some code.....Assume URL eventually gets populated with something!
// Create a CString to use as a parameter using URL....
CString urlParam(&URL); // don't forget to #include <atlstr.h>
// Above: If memory serves, from VS7 onwards CString can take a pointer to a system::String as a parameter in it's constructor when using the managed extensions... But I could be wrong!
// now call shellexecute passing the CString version of URL (urlParam)..
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.