-1

Trying to make a simple program that open a webpage when executed but I'm getting a parse error, and I don't know why.

#include <windows.h>
#include <shellapi.h>

bool open_browser()
{

    HINSTANCE result = ShellExecuteA( HWND, "open", "http://www.reddit.com", 
    NULL, NULL, SW_SHOWNORMAL );

    // Return whether or not we were successful.
    return (result);
}

int main( )
{
    open_browser();

    return 0;
}
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
AynonT
  • 225
  • 5
  • 13

2 Answers2

0

HWND is a type, not a value, so it's invalid as a function argument.

aschepler
  • 70,891
  • 9
  • 107
  • 161
0

you are passing a type, instead you should pass an instance of the HWND type

HWND myhwnd = ::CreateWindowA("STATIC", "reddit", WS_VISIBLE, 0, 0, 400, 600, NULL, NULL, NULL, NULL);
HINSTANCE result = ShellExecuteA(myhwnd, "open", "http://www.reddit.com", NULL, NULL, SW_SHOWNORMAL);
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
  • Thank you! but when i tried to compile it, I am getting a bunch of conflict errors from cygnus directory and there is no exec file being generated. – AynonT Apr 29 '17 at 22:52