-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.cpp
More file actions
88 lines (70 loc) · 1.85 KB
/
main.cpp
File metadata and controls
88 lines (70 loc) · 1.85 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#include <tchar.h>
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <process.h>
#include <cstdio>
#ifdef _WIN32
#include <direct.h>
// MSDN recommends against using getcwd & chdir names
#define cwd _getcwd
#define cd _chdir
#else
#include "unistd.h"
#define cwd getcwd
#define cd chdir
#endif
#include "vcredist.h"
using namespace std;
void getEXEPath(char *&exePath,
const char *szFileName)
{
// Get the last position of '/'
std::string aux(szFileName);
// get '/' or '\\' depending on unix/mac or windows.
#if defined(_WIN32) || defined(WIN32)
int pos = aux.rfind('\\');
#else
int pos = aux.rfind('/');
#endif
// Get the path and the name
std::string path = aux.substr(0, pos + 1);
char *path_array = new char[path.length() + 1];
strcpy(path_array, path.c_str());
exePath = path_array;
}
int WINAPI WinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
// get full EXEpath
TCHAR szFileName[MAX_PATH];
GetModuleFileName(NULL, szFileName, MAX_PATH);
/*
get basepath e.g. e:/phpbb/
*/
char *basePath = NULL;
getEXEPath(basePath, szFileName);
cd(basePath);
cd("bin\\bbwebkit");
STARTUPINFO info = {
sizeof(info)};
PROCESS_INFORMATION processInfo;
if (DoesVCRedistNeedUpdate())
{
TCHAR szVcRedistPath[MAX_PATH];
sprintf(szVcRedistPath, "%s\\bin\\vc_redist\\VC_redist.x64.exe", basePath);
UpdateVCRedist(szVcRedistPath);
}
if(!CreateProcess("bbwebkit.exe", NULL, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo)) {
MessageBoxA(NULL, "Unable to launch application", "Startup Failure", MB_OK | MB_ICONERROR);
}
return 0;
}