-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbrowser.cpp
More file actions
72 lines (54 loc) · 1.98 KB
/
Copy pathbrowser.cpp
File metadata and controls
72 lines (54 loc) · 1.98 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <windows.h>
#include <shellapi.h>
using namespace std;
void SearchWeb( string word );
void browser(string word){
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__)
printf("Not Windows\n");
system("open https://digitalbd.org");
#endif
#if defined(_WIN32) || defined(_WIN64) || defined(__TOS_WIN__) || defined(OS_WINDOWS) || defined(__WIN32__) || defined(__WINDOWS__)
printf("Windows\n");
SearchWeb(word);
#endif
}
int main(void)
{
// How to determine the version of the C++ standard used by the compiler?
if (__cplusplus == 201703L)
std::cout << "C++17" << endl;
else if (__cplusplus == 201402L)
std::cout << "C++14" << endl;
else if (__cplusplus == 201103L)
std::cout << "C++11" << endl;
else if (__cplusplus == 199711L)
std::cout << "C++98" << endl;
else
std::cout << "pre-standard C++" << endl;
//system("start https://digitalbd.org");
/// ShellExecute(NULL, "open", "http://www.microsoft.com", NULL, NULL, SW_SHOWNORMAL);
/// reference link https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/224816
string word;
cout<<"Enter a word to search\n";
cin>>word;
browser(word);
///SearchWeb(word);
return 0;
}
/// I've had MUCH better luck using ShellExecuteA().
/// I've heard that there are a lot of security risks when you use "system()".
/// This is what I came up with for my own code.
void SearchWeb( string word )
{
string base_URL = "http://www.bing.com/search?q=";
string search_URL = "dummy";
search_URL = base_URL + word;
cout << "Searching for: \"" << word << "\"\n";
ShellExecuteA(NULL, "open", search_URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
/// p.s. Its using WinAPI if i'm correct. So its not multiplatform solution.
/// If this is about starting a web browser from C++, you can invoke a shell command with system on a POSIX system:
/// system("<mybrowser> http://google.com");