Skip to content

Instantly share code, notes, and snippets.

@kagamilove0707
Created May 22, 2013 08:11
Show Gist options
  • Save kagamilove0707/5626006 to your computer and use it in GitHub Desktop.
Save kagamilove0707/5626006 to your computer and use it in GitHub Desktop.
クロスプラットホームでURLからブラウザを起動する関数ですー>ω< ただしOS Xでは動作確認していません、どなたか確認できたら連絡よろしくですー(-ω-)/
#include "openurl.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#endif
void openUrl(const char* url) {
#ifdef _WIN32
ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOW);
#endif
#ifdef _linux
char s[1000];
memset(s, 0, 1000);
sprintf(s, "xdg-open %s &",url);
system(s);
#endif
#ifdef __APPLE__
char s[1000];
memset(s, 0, 1000);
sprintf(s, "open %s &", url);
system(s);
#endif
}
#pragma once
void openUrl(const char* url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment