Showing multiple web pages with ShellExecute

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sundayCoder
    New Member
    • Mar 2014
    • 10

    Showing multiple web pages with ShellExecute

    Hello,
    I have question conserning ShellExecute.

    I have function like this:

    Code:
    void OpenURL(LPWSTR url) {
    //Notice! 6 parameters, not 7
    ShellExecute(NULL, L"open", url, NULL, NULL, NULL);
    }
    If I then use this function like this:

    Code:
    OpenURL(L"http://www.google.com/");
    OpenURL(L"http://bytes.com/");
    OpenURL(L"http://www.yahoo.com/");
    sometimes only the first web page is opened, but sometimes all of them. Could someone enlighten me what I should do so that all the web pages opened with OpenURL-function are always opened? Also, better ways to open web pages are very welcome. I use Visual Studio 2008 Express and Visual Studio 2013 Express.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I notice you are using wide strings: L"etc...".

    A wide string is not an LPWSTR. I suggest a call to MultiByteToWide Char to correctly translate and ASCII string into an LPWSTR.

    Let me know if this fixes your problem.

    Comment

    • sundayCoder
      New Member
      • Mar 2014
      • 10

      #3
      Thanks for the reply! It's been about 10 years since my previous c++ coding, so I'm kind of a beginner again (I had only experience in ANSI c++).

      My best try to use MultiByteToWide Char took me in situation where the compiler informed that "cannot convert parameter 1 from 'std::wstring' to 'LPWSTR'". So I need little more help with using MultiByteToWide Char (this is my first time using it).

      Could I have little sample code of converting ANSI string into an LPWSTR with MultiByteToWide Char?

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Try this: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

        Comment

        • sundayCoder
          New Member
          • Mar 2014
          • 10

          #5
          Thanks for the link! I got the conversion working now.

          At least so far it seems that the problem I described in my first post is gone, all the web pages I have tried to open with OpenURL-function have always been opened.

          So it seems that the problem occured because of wrong data types. Thanks! I learned new useful things.

          Comment

          Working...