summaryrefslogtreecommitdiffabout
path: root/install/install.cpp
blob: 12b20f76595600a9e18a6d4bd87378afd08741b4 (plain)
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
#include "resource.h"
#include "../shared-code/install.h"

#define KINSHORT "BigBro"
#define KINNAME "Big Brother"
#define VERSION "1.5"

BOOL Install(void)
{
STRING dPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group",KINSHORT "Path");
STRING kPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group","KINPath");
LPCSTR qPath = ((LPCSTR)dPath)?(LPCSTR)dPath:(((LPCSTR)kPath)?(LPSTR)kPath:"C:\\Program Files\\Klever\\Nothings");
STRING path = REQUESTPATH("  " KINNAME " " VERSION,"\nEnter destination path:",qPath);
	if(!path)
		return NULL;

#ifdef	K_ANNED
STRING sysDir(_MAX_PATH);
	GetSystemDirectory(sysDir,_MAX_PATH);
	INSTALLFILE("mfc42.dl_",sysDir,"mfc42.dll");
#endif

	MAKE_PATH(path);
STRING shortPath = GET_SHORT_PATH(path);
	if(!shortPath){
		MessageBox(NULL,"Failed to install " KINNAME " " VERSION " in specified directory",NULL,MB_ICONERROR|MB_OK);
		return FALSE;
	}

	if(!(
		INSTALLFILE("bigbro.ex_",path,"bigbro.exe") &&
		INSTALLFILE("bigbro.hl_",path,"bigbro.hlp") && 
		INSTALLFILE("bigbro.cn_",path,"bigbro.cnt")
	)){
		MessageBox(NULL,"Failed to install " KINNAME " " VERSION " in specified directory",NULL,MB_ICONERROR|MB_OK);
		return FALSE;
	}
	ADDMENU("Klever Group",KINNAME,path,"bigbro.exe");

	strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group",KINSHORT "Path",path);
	strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group","KINPath",path);

FILE* inf=CREATE_INF_FILE(path,KINSHORT ".INF");
	if(!inf){
		MessageBox(NULL,"Failed to install " KINNAME " " VERSION,NULL,MB_ICONERROR|MB_OK);
		return FALSE;
	}
	INF_FILE_HEADER(inf);
	INF_FILE_SECTION(inf,"Uninstall");
	fprintf(inf,"AddReg=kFiles\nDelReg=kReg\nUpdateInis=kMenu\n");
	INF_FILE_SECTION(inf,"kFiles");
	INF_REMOVE_ROOT(inf,KINSHORT "Files",path);
	INF_REMOVE_FILE(inf,KINSHORT "Files","bigbro.exe");
	INF_REMOVE_HELP_FILE(inf,KINSHORT "Files","bigbro");
	INF_REMOVE_FILE(inf,KINSHORT "Files","bigbro.inf");
	INF_FILE_SECTION(inf,"kReg");
	INF_UNINSTALL_REG(inf,KINSHORT);
	INF_FILE_SECTION(inf,"kMenu");
	INF_MENU_GROUP(inf,1,"Klever Group");
	INF_MENU_ITEM(inf,1,KINNAME);
	fclose(inf);

	REG_UNINSTALL_COMMAND(KINSHORT,"Klever " KINNAME " " VERSION,shortPath,KINSHORT".INF","Uninstall");

	MessageBox(NULL,KINNAME" " VERSION " installed successfully, you may now run it from 'Programs/Klever Group' menu or remove it using Control Panel Add/Remove Programs applet."," Rejoice!",MB_ICONINFORMATION|MB_OK);

	return TRUE;
}