0

Topic title is not the best but nvm


I have been looking for this on internet but cant it find anything useful.

#include <windows.h>

void main()
{
   ShellExecute(NULL, "open", "http://dreamincode.net",
                NULL, NULL, SW_SHOWNORMAL);
}

This is function which I have found on net to open URL, problem of this function is if I want to open 2 URLs I need to have 2 functions instead of one.

What I need is something like this, but I cant implement it.

void openURL (string& URL){

      ShellExecute(NULL, "open", URL,
                NULL, NULL, SW_SHOWNORMAL);
}
2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Jeronim
0

Since URL is std::string you have to use its c_str() method

void openURL (string& URL){

      ShellExecute(NULL, "open", URL.c_str(),
                NULL, NULL, SW_SHOWNORMAL);
}

Edited by Ancient Dragon: n/a

0

It doesn't work :(

Same compiler error as before

error C2664: 'ShellExecuteW' : cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'

EDIT: I have tested the same code in DEV and it works, in VS it doesn't.

Edited by Jeronim: n/a

2

The problem is that vc++ uses UNICODE strings by default. You have to go to project settings and change it. Select menu Project --> Properties (the last menu item in the list) --> Configuration Properties --> General. Then on the right sice of the screen, near the bottom of the list change "Character Set" to "Not Set".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.