简体   繁体   中英

error when i tried opening a website with windows.h library

#include<iostream>
#include <windows.h>
#include<string>
using namespace std;

int main()
{

cout << "Opening Google...";
ShellExecute(NULL, L"open", L"https://www.google.com",NULL, NULL,   SW_SHOWNORMAL);




return 0;

}

I get this error: Cannot convert 'const wchart_t*' to 'LPCSTR{aka const char*}\\ for argument '2' to 'HINSTANCE_*SHellExecuteA(HWND,LPCSTR,LPCSTR, LPCSTR, LPCSTR, INT)'

You have 2 capabilities:

  1. As @chris noted, you can compile you program with UNICODE defined
  2. You can use special macros for string literals for more flexibility

    ShellExecute(NULL, TEXT("open"), TEXT(" https://www.google.com "), NULL, NULL,
    SW_SHOWNORMAL);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM