-
Notifications
You must be signed in to change notification settings - Fork 2
/
oexplore.c
60 lines (58 loc) · 1.69 KB
/
oexplore.c
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
#include <windows.h>
#include <exdisp.h>
#include <shellapi.h>
int start()
{
CoInitialize(NULL);
IWebBrowser2* pWebBrowser2 = NULL;
HRESULT hr = CoCreateInstance(
&CLSID_InternetExplorer,
NULL,
CLSCTX_LOCAL_SERVER,
&IID_IWebBrowser2,
(void**)&pWebBrowser2);
if (SUCCEEDED(hr))
{
hr = pWebBrowser2->lpVtbl->put_Visible(
pWebBrowser2, VARIANT_TRUE);
if (SUCCEEDED(hr))
{
LPCWSTR commandLine = GetCommandLineW();
int args = 0;
LPWSTR* argv = CommandLineToArgvW(commandLine, &args);
BSTR url = SysAllocString(
args >= 2 ? argv[1] : L"http://www.bing.com/");
LocalFree(argv);
hr = pWebBrowser2->lpVtbl->Navigate(
pWebBrowser2, url, NULL, NULL, NULL, NULL);
if (FAILED(hr))
{
MessageBoxW(
NULL,
L"Couldn't navigate.",
L"Outernet Explorer",
MB_OK | MB_ICONEXCLAMATION);
}
SysFreeString(url);
}
else
{
MessageBoxW(
NULL,
L"Couldn't show Internet Explorer component.",
L"Outernet Explorer",
MB_OK | MB_ICONEXCLAMATION);
}
pWebBrowser2->lpVtbl->Release(pWebBrowser2);
}
else
{
MessageBoxW(
NULL,
L"Couldn't instantiate Internet Explorer component.",
L"Outernet Explorer",
MB_OK | MB_ICONEXCLAMATION);
}
CoUninitialize();
ExitProcess(hr);
}