1 | // AbuseInstallerDlg.cpp : implementation file
|
---|
2 | //
|
---|
3 |
|
---|
4 | #include "stdafx.h"
|
---|
5 | #include "AbuseInstaller.h"
|
---|
6 | #include "AbuseInstallerDlg.h"
|
---|
7 | #include "afxdisp.h"
|
---|
8 |
|
---|
9 | #ifdef _DEBUG
|
---|
10 | #define new DEBUG_NEW
|
---|
11 | #undef THIS_FILE
|
---|
12 | static char THIS_FILE[] = __FILE__;
|
---|
13 | #endif
|
---|
14 |
|
---|
15 | /////////////////////////////////////////////////////////////////////////////
|
---|
16 | // CAbuseInstallerDlg dialog
|
---|
17 |
|
---|
18 | CAbuseInstallerDlg::CAbuseInstallerDlg(CWnd* pParent /*=NULL*/)
|
---|
19 | : CDialog(CAbuseInstallerDlg::IDD, pParent)
|
---|
20 | {
|
---|
21 | //{{AFX_DATA_INIT(CAbuseInstallerDlg)
|
---|
22 | // NOTE: the ClassWizard will add member initialization here
|
---|
23 | //}}AFX_DATA_INIT
|
---|
24 | // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
---|
25 | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
---|
26 | InitInstance();
|
---|
27 | }
|
---|
28 |
|
---|
29 | void CAbuseInstallerDlg::DoDataExchange(CDataExchange* pDX)
|
---|
30 | {
|
---|
31 | CDialog::DoDataExchange(pDX);
|
---|
32 | //{{AFX_DATA_MAP(CAbuseInstallerDlg)
|
---|
33 | // NOTE: the ClassWizard will add DDX and DDV calls here
|
---|
34 | //}}AFX_DATA_MAP
|
---|
35 | }
|
---|
36 |
|
---|
37 | BOOL CAbuseInstallerDlg::InitInstance()
|
---|
38 | {
|
---|
39 | AfxEnableControlContainer();
|
---|
40 | return TRUE;
|
---|
41 | }
|
---|
42 |
|
---|
43 | BEGIN_MESSAGE_MAP(CAbuseInstallerDlg, CDialog)
|
---|
44 | //{{AFX_MSG_MAP(CAbuseInstallerDlg)
|
---|
45 | ON_WM_PAINT()
|
---|
46 | ON_WM_QUERYDRAGICON()
|
---|
47 | ON_WM_LBUTTONDOWN()
|
---|
48 | ON_WM_LBUTTONUP()
|
---|
49 | ON_BN_CLICKED(IDC_INSTALL_PLAY_BUTTON, OnInstallPlayButtonClick)
|
---|
50 | //}}AFX_MSG_MAP
|
---|
51 | END_MESSAGE_MAP()
|
---|
52 |
|
---|
53 | /////////////////////////////////////////////////////////////////////////////
|
---|
54 | // CAbuseInstallerDlg message handlers
|
---|
55 |
|
---|
56 | BOOL CAbuseInstallerDlg::OnInitDialog()
|
---|
57 | {
|
---|
58 | CDialog::OnInitDialog();
|
---|
59 |
|
---|
60 | // Set the icon for this dialog. The framework does this automatically
|
---|
61 | // when the application's main window is not a dialog
|
---|
62 | SetIcon(m_hIcon, TRUE); // Set big icon
|
---|
63 | SetIcon(m_hIcon, FALSE); // Set small icon
|
---|
64 |
|
---|
65 | // TODO: Add extra initialization here
|
---|
66 |
|
---|
67 | HKEY InstalledKey;
|
---|
68 |
|
---|
69 | unsigned char ExePath[1024];
|
---|
70 | ZeroMemory(ExePath, sizeof(ExePath));
|
---|
71 | long result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\PosseSoft\\Abuse32", 0, KEY_READ, &InstalledKey);
|
---|
72 | if (result == ERROR_SUCCESS) {
|
---|
73 | unsigned long Type, DataSize;
|
---|
74 | result = RegQueryValueEx(InstalledKey, "InstallDir", NULL, &Type, ExePath, &DataSize);
|
---|
75 | strcat((char*) ExePath, "\\uninst.isu");
|
---|
76 | if (result == ERROR_SUCCESS) {
|
---|
77 | CFileFind Find;
|
---|
78 | if (Find.FindFile((LPCSTR) ExePath)) {
|
---|
79 | PostQuitMessage(0);
|
---|
80 | _RPT0(_CRT_WARN, "Abuse found; Exiting.\n");
|
---|
81 | }
|
---|
82 | }
|
---|
83 | }
|
---|
84 | return TRUE; // return TRUE unless you set the focus to a control
|
---|
85 | }
|
---|
86 |
|
---|
87 | // If you add a minimize button to your dialog, you will need the code below
|
---|
88 | // to draw the icon. For MFC applications using the document/view model,
|
---|
89 | // this is automatically done for you by the framework.
|
---|
90 |
|
---|
91 | void CAbuseInstallerDlg::OnPaint()
|
---|
92 | {
|
---|
93 | if (IsIconic())
|
---|
94 | {
|
---|
95 | CPaintDC dc(this); // device context for painting
|
---|
96 |
|
---|
97 | SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
|
---|
98 |
|
---|
99 | // Center icon in client rectangle
|
---|
100 | int cxIcon = GetSystemMetrics(SM_CXICON);
|
---|
101 | int cyIcon = GetSystemMetrics(SM_CYICON);
|
---|
102 | CRect rect;
|
---|
103 | GetClientRect(&rect);
|
---|
104 | int x = (rect.Width() - cxIcon + 1) / 2;
|
---|
105 | int y = (rect.Height() - cyIcon + 1) / 2;
|
---|
106 |
|
---|
107 | // Draw the icon
|
---|
108 | dc.DrawIcon(x, y, m_hIcon);
|
---|
109 | }
|
---|
110 | else
|
---|
111 | {
|
---|
112 | CDialog::OnPaint();
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | // The system calls this to obtain the cursor to display while the user drags
|
---|
117 | // the minimized window.
|
---|
118 | HCURSOR CAbuseInstallerDlg::OnQueryDragIcon()
|
---|
119 | {
|
---|
120 | return (HCURSOR) m_hIcon;
|
---|
121 | }
|
---|
122 |
|
---|
123 | void CAbuseInstallerDlg::OnInstallPlayButtonClick()
|
---|
124 | {
|
---|
125 | // TODO: Add your control notification handler code here
|
---|
126 | PROCESS_INFORMATION ProcessInfo;
|
---|
127 | STARTUPINFO StartupInfo;
|
---|
128 | ZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
---|
129 | StartupInfo.cb = sizeof(StartupInfo);
|
---|
130 | CreateProcess("Install\\Abuse Setup.exe", "", NULL, NULL, FALSE, 0, NULL, "Install\\", &StartupInfo, &ProcessInfo);
|
---|
131 | }
|
---|