Help launching google chrome

I'm trying to launch google chrome from a program, but it won't work. It opens up the console and absolutely nothing happens. I've tried the below.

1
2
3
4
5
6
7
8
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
WinExec("C: Program Files(x86)\\Google\\Chrome\\chrome.exe", SW_SHOW);
}

I've tried this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <windows.h>
#include <shellapi.h>
#include <shlobj.h>
#include <assert.h>
#pragma comment(lib, "shell32.lib")
bool open_browser( const char* url, HWND parent = NULL )
  {
  // Try normally, with the default verb (which will typically be "open")
  HINSTANCE result = ShellExecuteA( parent, NULL, url, NULL, NULL, SW_SHOWNORMAL );

  // If that fails due to privileges, let's ask for more and try again
  if ((int)result == SE_ERR_ACCESSDENIED)
    result = ShellExecuteA( parent, "runas", url, NULL, NULL, SW_SHOWNORMAL );

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

int main( int argc, char** argv )
  {
  // For simple example, just prevent the most basic error.
  if (argc != 2) return 1;


  open_browser( argv[ 1 ] );

  return 0;
  }

Last edited on
Topic archived. No new replies allowed.