3 Part of the swftools installer (Main program).
5 Copyright (c) 2004 Matthias Kramm <kramm@quiss.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
28 #include "installer.h"
32 #include "../config.h" //for swftools version
34 static int config_forAllUsers = 0;
35 static int config_createLinks = 0;
36 static int config_createStartmenu = 1;
37 static int config_createDesktop = 1;
39 static char path_startmenu[MAX_PATH] = "\0";
40 static char path_desktop[MAX_PATH] = "\0";
41 static char path_programfiles[MAX_PATH] = "\0";
44 extern char*license_text;
46 static char*install_path = "c:\\swftools\\";
47 static char pathBuf[MAX_PATH];
48 static int do_abort = 0;
50 static char* pdf2swf_path;
52 static HBITMAP logo = 0;
56 #define USER_SETMESSAGE 0x7f01
58 static void tball(HDC hdc, double px, double py, double sx, double sy)
60 MoveToEx(hdc, 75.25*sx+px, -32.50*sy+py, 0);
61 LineTo(hdc, 74.75*sx+px, -24.80*sy+py); LineTo(hdc, 74.95*sx+px, -3.45*sy+py); LineTo(hdc, 75.25*sx+px, -32.50*sy+py);
62 LineTo(hdc, 44.85*sx+px, -104.30*sy+py); LineTo(hdc, 74.75*sx+px, -24.80*sy+py); LineTo(hdc, 17.30*sx+px, -91.80*sy+py);
63 LineTo(hdc, 29.35*sx+px, -10.10*sy+py); LineTo(hdc, 74.75*sx+px, -24.80*sy+py); LineTo(hdc, 47.60*sx+px, 63.80*sy+py);
64 LineTo(hdc, 74.75*sx+px, 51.10*sy+py); LineTo(hdc, 74.95*sx+px, -3.45*sy+py);
65 MoveToEx(hdc, 74.75*sx+px, 51.10*sy+py, 0);
66 LineTo(hdc, 29.35*sx+px, 118.75*sy+py); LineTo(hdc, -45.20*sx+px, 155.35*sy+py);
67 LineTo(hdc, -127.95*sx+px, 145.10*sy+py); LineTo(hdc, -194.85*sx+px, 104.30*sy+py);
68 LineTo(hdc, -225.25*sx+px, 32.50*sy+py); LineTo(hdc, -224.75*sx+px, -51.10*sy+py);
69 LineTo(hdc, -179.35*sx+px, -118.75*sy+py); LineTo(hdc, -104.80*sx+px, -155.35*sy+py);
70 LineTo(hdc, -22.05*sx+px, -145.10*sy+py); LineTo(hdc, 44.85*sx+px, -104.30*sy+py);
71 LineTo(hdc, 17.30*sx+px, -91.80*sy+py); LineTo(hdc, -75.00*sx+px, -122.60*sy+py);
72 LineTo(hdc, -45.20*sx+px, -43.70*sy+py); LineTo(hdc, 17.30*sx+px, -91.80*sy+py);
73 LineTo(hdc, -22.05*sx+px, -145.10*sy+py); LineTo(hdc, -75.00*sx+px, -122.60*sy+py);
74 LineTo(hdc, -104.80*sx+px, -155.35*sy+py); LineTo(hdc, -167.30*sx+px, -107.25*sy+py);
75 LineTo(hdc, -75.00*sx+px, -122.60*sy+py); LineTo(hdc, -127.95*sx+px, -63.55*sy+py);
76 LineTo(hdc, -45.20*sx+px, -43.70*sy+py); LineTo(hdc, 29.35*sx+px, -10.10*sy+py);
77 LineTo(hdc, 47.60*sx+px, 63.80*sy+py); LineTo(hdc, -25.70*sx+px, 52.45*sy+py);
78 LineTo(hdc, -25.70*sx+px, 128.45*sy+py); LineTo(hdc, 47.60*sx+px, 63.80*sy+py);
79 LineTo(hdc, 29.35*sx+px, 118.75*sy+py); LineTo(hdc, -25.70*sx+px, 128.45*sy+py);
80 LineTo(hdc, -45.20*sx+px, 155.35*sy+py); LineTo(hdc, -118.85*sx+px, 143.85*sy+py);
81 LineTo(hdc, -127.95*sx+px, 145.10*sy+py);
82 MoveToEx(hdc, -179.35*sx+px, -118.75*sy+py, 0);
83 LineTo(hdc, -167.30*sx+px, -107.25*sy+py); LineTo(hdc, -127.95*sx+px, -63.55*sy+py);
84 LineTo(hdc, -118.85*sx+px, 21.65*sy+py); LineTo(hdc, -45.20*sx+px, -43.70*sy+py);
85 LineTo(hdc, -25.70*sx+px, 52.45*sy+py); LineTo(hdc, 29.35*sx+px, -10.10*sy+py);
86 MoveToEx(hdc, -225.25*sx+px, 32.50*sy+py, 0);
87 LineTo(hdc, -194.85*sx+px, -17.85*sy+py); LineTo(hdc, -224.75*sx+px, -51.10*sy+py);
88 LineTo(hdc, -167.30*sx+px, -107.25*sy+py); LineTo(hdc, -194.85*sx+px, -17.85*sy+py);
89 LineTo(hdc, -127.95*sx+px, -63.55*sy+py);
90 MoveToEx(hdc, -175.85*sx+px, 77.60*sy+py, 0);
91 LineTo(hdc, -96.35*sx+px, 99.55*sy+py); LineTo(hdc, -118.85*sx+px, 21.65*sy+py);
92 LineTo(hdc, -175.85*sx+px, 77.60*sy+py); LineTo(hdc, -225.25*sx+px, 32.50*sy+py);
93 MoveToEx(hdc, -118.85*sx+px, 143.85*sy+py, 0);
94 LineTo(hdc, -175.85*sx+px, 77.60*sy+py); LineTo(hdc, -194.85*sx+px, 104.30*sy+py);
95 LineTo(hdc, -118.85*sx+px, 143.85*sy+py); LineTo(hdc, -96.35*sx+px, 99.55*sy+py);
96 LineTo(hdc, -25.70*sx+px, 52.45*sy+py); LineTo(hdc, -118.85*sx+px, 21.65*sy+py);
97 LineTo(hdc, -194.85*sx+px, -17.85*sy+py); LineTo(hdc, -175.85*sx+px, 77.60*sy+py);
98 MoveToEx(hdc, -96.35*sx+px, 99.55*sy+py, 0);
99 LineTo(hdc, -25.70*sx+px, 128.45*sy+py); LineTo(hdc, -118.85*sx+px, 143.85*sy+py);
102 static char* concatPaths(const char*base, const char*add)
104 int l1 = strlen(base);
105 int l2 = strlen(add);
108 while(l1 && base[l1-1] == '\\')
110 while(pos < l2 && add[pos] == '\\')
113 n = (char*)malloc(l1 + (l2-pos) + 2);
116 strcpy(&n[l1+1],&add[pos]);
120 static void handleTemplateFile(const char*filename)
122 FILE*fi = fopen(filename, "rb");
123 fseek(fi, SEEK_END, 0);
125 fseek(fi, SEEK_SET, 0);
126 char*file = malloc(len);
127 fread(file, len, 1, fi);
129 int l = strlen(install_path);
130 fi = fopen(filename, "wb");
134 pos = strstr(pos, "%%PATH%%");
140 fwrite(lastpos, pos-lastpos, 1, fi);
141 fwrite(install_path, l, 1, fi);
142 pos+=8; // length of "%%PATH%%"
145 fwrite(lastpos, pos-lastpos, 1, fi);
150 static char* getRegistryEntry(char*path)
158 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, path, 0, KEY_ALL_ACCESS/* KEY_READ*/, &key);
159 if (rc != ERROR_SUCCESS) {
160 fprintf(stderr, "RegOpenKeyEx failed\n");
163 rc = RegQueryValueEx(key, NULL, 0, 0, 0, (LPDWORD)&size) ;
164 if(rc != ERROR_SUCCESS) {
165 fprintf(stderr, "RegQueryValueEx(1) failed: %d\n", rc);
168 buf = (char*)malloc(size+1);
169 rc = RegQueryValueEx(key, NULL, 0, &type, (BYTE*)buf, (LPDWORD)&size);
170 if(rc != ERROR_SUCCESS) {
171 fprintf(stderr, "RegQueryValueEx(2) failed: %d\n", rc);
174 if(type == REG_SZ || type == REG_EXPAND_SZ) {
175 while(size && buf[size-1] == '\0')
180 } else if(type == REG_BINARY) {
185 static int setRegistryEntry(char*key,char*value)
189 int ret1 = -1, ret2= -1;
190 ret1 = RegCreateKey(HKEY_CURRENT_USER, key, &hkey1);
191 if(config_forAllUsers) {
192 ret2 = RegCreateKey(HKEY_LOCAL_MACHINE, key, &hkey2);
196 fprintf(stderr, "registry: CreateKey %s failed\n", key);
200 ret1 = RegSetValue(hkey1, NULL, REG_SZ, value, strlen(value)+1);
202 ret2 = RegSetValue(hkey2, NULL, REG_SZ, value, strlen(value)+1);
204 fprintf(stderr, "registry: SetValue %s failed\n", key);
210 static HWND wnd_background = 0;
211 LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
213 if(message == WM_CREATE) {
214 CREATESTRUCT*cs = ((LPCREATESTRUCT)lParam);
215 if(cs->lpCreateParams && !strcmp((char*)cs->lpCreateParams, "background")) {
216 wnd_background = hwnd;
219 if(hwnd == wnd_background && message == WM_PAINT) {
223 GetWindowRect(hwnd, &rc);
224 int width = rc.right - rc.left;
225 int height = rc.bottom - rc.top;
227 hdc = BeginPaint(hwnd, &ps);
228 SetBkMode(hdc, TRANSPARENT);
230 double s = width / 1282.0;
232 HPEN pen0 = CreatePen(PS_SOLID, 2, RGB(0, 32, 128));
233 HPEN oldPen = (HPEN)SelectObject(hdc, pen0);
234 tball(hdc, 0.7*width,0.2*height,s,s);
236 HPEN pen1 = CreatePen(PS_SOLID, 2, RGB(0, 48, 128));
237 (HPEN)SelectObject(hdc, pen1);
238 tball(hdc, 0.233*width,0.3*height,s*2,s*2);
240 HPEN pen2 = CreatePen(PS_SOLID, 2, RGB(0, 64, 128));
241 (HPEN)SelectObject(hdc, pen2);
242 tball(hdc, width, 1.2*height,s*3,-s*3);
244 SelectObject(hdc, oldPen);
250 return DefWindowProc(hwnd, message, wParam, lParam);
253 void processMessages()
256 while(PeekMessage(&msg,NULL,0,0,0))
258 GetMessage(&msg, NULL, 0, 0);
259 TranslateMessage(&msg);
260 DispatchMessage(&msg);
264 int addRegistryEntries(char*install_dir)
267 ret = setRegistryEntry("Software\\quiss.org\\swftools\\InstallPath", install_dir);
272 int CreateShortcut(char*path, char*description, char*filename, char*arguments, int iconindex, char*iconpath, char*workdir)
274 WCHAR wszFilename[MAX_PATH];
275 IShellLink *ps1 = NULL;
276 IPersistFile *pPf = NULL;
278 hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (void*)&ps1);
279 if(FAILED(hr)) return 0;
280 hr = ps1->lpVtbl->QueryInterface(ps1, &IID_IPersistFile, (void **)&pPf);
281 if(FAILED(hr)) return 0;
282 hr = ps1->lpVtbl->SetPath(ps1, path);
283 if(FAILED(hr)) return 0;
284 hr = ps1->lpVtbl->SetDescription(ps1, description);
287 hr = ps1->lpVtbl->SetArguments(ps1, arguments);
288 if(FAILED(hr)) return 0;
291 hr = ps1->lpVtbl->SetIconLocation(ps1, iconpath, iconindex);
292 if (FAILED(hr)) return 0;
295 hr = ps1->lpVtbl->SetWorkingDirectory(ps1, workdir);
296 if (FAILED(hr)) return 0;
298 MultiByteToWideChar(CP_ACP, 0, filename, -1, wszFilename, MAX_PATH);
299 hr = pPf->lpVtbl->Save(pPf, wszFilename, TRUE);
303 pPf->lpVtbl->Release(pPf);
304 ps1->lpVtbl->Release(ps1);
308 static int CreateURL(const char*url, const char*path)
310 FILE*fi = fopen(path, "wb");
313 fprintf(fi, "[InternetShortcut]\r\n");
314 fprintf(fi, "URL=http://localhost:8081/\r\n");
320 BOOL CALLBACK PropertySheetFuncCommon(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, int buttons)
324 HWND dialog = GetParent(hwnd);
326 if(message == WM_INITDIALOG) {
328 SendDlgItemMessage(hwnd, IDC_BITMAP, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)logo);
331 GetWindowRect(dialog, &rc);
332 int width = rc.right - rc.left;
333 int height = rc.bottom - rc.top;
334 MoveWindow(dialog, (GetSystemMetrics(SM_CXSCREEN) - width)/2, (GetSystemMetrics(SM_CYSCREEN) - height)/2, width, height, FALSE);
338 if(message == WM_NOTIFY && (((LPNMHDR)lParam)->code == PSN_SETACTIVE)) {
339 PropSheet_SetWizButtons(dialog, buttons);
345 BOOL CALLBACK PropertySheetFunc1(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
346 if(message == WM_INITDIALOG) {
347 SetDlgItemText(hwnd, IDC_LICENSE, license_text);
349 return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_NEXT);
351 BOOL CALLBACK PropertySheetFunc2(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
352 if(message == WM_INITDIALOG) {
353 SetDlgItemText(hwnd, IDC_INSTALL_PATH, install_path);
355 config_forAllUsers = 0;
356 SendDlgItemMessage(hwnd, IDC_ALLUSERS, BM_SETCHECK, config_forAllUsers, 0);
357 SendDlgItemMessage(hwnd, IDC_CURRENTUSER, BM_SETCHECK, config_forAllUsers^1, 0);
359 if(message == WM_COMMAND) {
360 if((wParam&0xffff) == IDC_BROWSE) {
362 memset(&browse, 0, sizeof(browse));
363 browse.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_USENEWUI;// | BIF_RETURNONLYFSDIRS; //BIF_VALIDATE
364 browse.pszDisplayName = (CHAR*)malloc(MAX_PATH);
365 memset(browse.pszDisplayName, 0, MAX_PATH);
366 browse.lpszTitle = "Select installation directory";
367 printf("Start browsing %s\n", browse.pszDisplayName);
368 browse.pidlRoot = SHBrowseForFolder(&browse);
369 printf("Browsing returns %s / %08x\n", browse.pszDisplayName, browse.pidlRoot);
370 if(browse.pszDisplayName) {
371 if(SHGetPathFromIDList(browse.pidlRoot, browse.pszDisplayName)) {
372 printf("Path is %s\n", browse.pszDisplayName);
373 install_path = browse.pszDisplayName;
374 int l = strlen(install_path);
375 while(l && install_path[l-1]=='\\') {
380 SendDlgItemMessage(hwnd, IDC_INSTALL_PATH, WM_SETTEXT, 0, (LPARAM)install_path);
384 else if((wParam&0xffff) == IDC_ALLUSERS) {
385 config_forAllUsers = 1;
386 SendDlgItemMessage(hwnd, IDC_ALLUSERS, BM_SETCHECK, config_forAllUsers, 0);
387 SendDlgItemMessage(hwnd, IDC_CURRENTUSER, BM_SETCHECK, config_forAllUsers^1, 0);
389 else if((wParam&0xffff) == IDC_CURRENTUSER) {
390 config_forAllUsers = 0;
391 SendDlgItemMessage(hwnd, IDC_ALLUSERS, BM_SETCHECK, config_forAllUsers, 0);
392 SendDlgItemMessage(hwnd, IDC_CURRENTUSER, BM_SETCHECK, config_forAllUsers^1, 0);
394 else if((wParam&0xffff) == IDC_INSTALL_PATH) {
395 SendDlgItemMessage(hwnd, IDC_INSTALL_PATH, WM_GETTEXT, sizeof(pathBuf), (LPARAM)&(pathBuf[0]));
397 install_path = pathBuf;
398 int l = strlen(install_path);
399 while(l && install_path[l-1]=='\\') {
406 return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_BACK|PSWIZB_NEXT);
409 static int progress_pos = 0;
410 void PropertyArchiveStatus(int type, char*text)
412 if(text && text[0]=='[') return;
413 SetDlgItemText(statuswnd, IDC_INFO, strdup(text));
415 /* There are usually 6 messages, and a range of 54 to fill, so
418 SendDlgItemMessage(statuswnd, IDC_PROGRESS, PBM_SETPOS, ++progress_pos, 0);
424 int ret = MessageBox(0, text, "Error", MB_RETRYCANCEL|MB_ICONERROR);
425 if(ret==IDRETRY) continue;
430 BOOL CALLBACK PropertySheetFunc3(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
431 HWND dialog = GetParent(hwnd);
432 if(message == WM_INITDIALOG) {
433 SetDlgItemText(hwnd, IDC_INFO, "Ready to install");
435 if(message == WM_NOTIFY && (((LPNMHDR)lParam)->code == PSN_WIZNEXT)) {
436 PropSheet_SetWizButtons(dialog, 0);
437 SendMessage(dialog, PSM_CANCELTOCLOSE, 0, 0); //makes wine display a warning
438 SetDlgItemText(hwnd, IDC_TITLE, "Installing files...");
440 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0, (LPARAM)MAKELONG(0,54));
442 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, progress_pos, 0);
443 int success = unpack_archive(crndata, install_path, PropertyArchiveStatus);
446 return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_BACK|PSWIZB_NEXT);
449 static HRESULT (WINAPI *f_SHGetSpecialFolderPath)(HWND hwnd, LPTSTR lpszPath, int nFolder, BOOL fCreate);
451 BOOL CALLBACK PropertySheetFunc4(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
452 if(message == WM_INITDIALOG) {
453 pdf2swf_path = concatPaths(install_path, "pdf2swf_gui.exe");
454 FILE*fi = fopen(pdf2swf_path, "rb");
456 config_createLinks = 1;
459 if(!config_createLinks) {
460 SendDlgItemMessage(hwnd, IDC_STARTMENU, SW_HIDE, 0, 0);
461 SendDlgItemMessage(hwnd, IDC_DESKTOP, SW_HIDE, 0, 0);
464 SendDlgItemMessage(hwnd, IDC_STARTMENU, BM_SETCHECK, config_createStartmenu, 0);
465 SendDlgItemMessage(hwnd, IDC_DESKTOP, BM_SETCHECK, config_createStartmenu, 0);
467 if(message == WM_COMMAND) {
468 if((wParam&0xffff) == IDC_STARTMENU) {
469 config_createStartmenu = SendDlgItemMessage(hwnd, IDC_STARTMENU, BM_GETCHECK, 0, 0);
470 config_createStartmenu^=1;
471 SendDlgItemMessage(hwnd, IDC_STARTMENU, BM_SETCHECK, config_createStartmenu, 0);
474 if((wParam&0xffff) == IDC_DESKTOP) {
475 config_createDesktop = SendDlgItemMessage(hwnd, IDC_DESKTOP, BM_GETCHECK, 0, 0);
476 config_createDesktop^=1;
477 SendDlgItemMessage(hwnd, IDC_DESKTOP, BM_SETCHECK, config_createDesktop, 0);
482 if(message == WM_NOTIFY && (((LPNMHDR)lParam)->code == PSN_WIZFINISH)) {
483 if(!addRegistryEntries(install_path)) {
484 MessageBox(0, "Couldn't create Registry Entries", "SWFTools Install", MB_OK|MB_ICONERROR);
488 char mypath[MAX_PATH];
489 path_startmenu[0] = 0;
491 if(config_forAllUsers) {
492 f_SHGetSpecialFolderPath(NULL, path_desktop, CSIDL_COMMON_DESKTOPDIRECTORY, 0);
493 f_SHGetSpecialFolderPath(NULL, path_startmenu, CSIDL_COMMON_PROGRAMS, 0);
495 /* get local program/desktop directory- this is both for forAllUsers=0 as well
496 as a fallback if the above didn't return any paths */
497 if(!path_startmenu[0]) {
498 f_SHGetSpecialFolderPath(NULL, path_startmenu, CSIDL_PROGRAMS, 0);
500 if(!path_desktop[0]) {
501 f_SHGetSpecialFolderPath(NULL, path_desktop, CSIDL_DESKTOPDIRECTORY, 0);
504 if(config_createLinks) {
505 if(config_createDesktop && path_desktop[0]) {
506 char* linkName = concatPaths(path_desktop, "pdf2swf.lnk");
507 printf("Creating desktop link %s -> %s\n", linkName, pdf2swf_path);
508 if(!CreateShortcut(pdf2swf_path, "pdf2swf", linkName, 0, 0, 0, install_path)) {
509 MessageBox(0, "Couldn't create desktop shortcut", "Install.exe", MB_OK);
513 if(config_createStartmenu && path_startmenu[0]) {
514 char* group = concatPaths(path_startmenu, "pdf2swf");
515 CreateDirectory(group, 0);
516 char* linkName = concatPaths(group, "pdf2swf.lnk");
517 printf("Creating %s -> %s\n", linkName, pdf2swf_path);
518 if(!CreateShortcut(pdf2swf_path, "pdf2swf", linkName, 0, 0, 0, install_path)) {
519 MessageBox(0, "Couldn't create start menu entry", "Install.exe", MB_OK);
524 printf("not creating desktop/startmenu links\n");
527 return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_FINISH);
530 #ifndef PSP_HIDEHEADER
531 #define PSP_HIDEHEADER 2048
534 typedef struct _wizardpage {
539 void runPropertySheet(HWND parent)
541 PROPSHEETHEADER sheet;
543 wizardpage_t wpage[5] = {
544 {PropertySheetFunc1, IDD_LICENSE},
545 {PropertySheetFunc2, IDD_INSTALLDIR},
546 {PropertySheetFunc3, IDD_PROGRESS},
547 {PropertySheetFunc4, IDD_FINISH},
549 int num = sizeof(wpage)/sizeof(wpage[0]);
550 HPROPSHEETPAGE pages[num];
554 memset(&page, 0, sizeof(PROPSHEETPAGE));
555 page.dwSize = sizeof(PROPSHEETPAGE);
556 page.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER;
558 page.pfnDlgProc = wpage[t].function;
559 page.pszTemplate = MAKEINTRESOURCE(wpage[t].resource);
560 pages[t] = CreatePropertySheetPage(&page);
563 memset(&sheet, 0, sizeof(PROPSHEETHEADER));
564 sheet.dwSize = sizeof(PROPSHEETHEADER);
565 sheet.hInstance = me;
566 sheet.hwndParent = parent;
567 sheet.phpage = pages;
568 sheet.dwFlags = PSH_WIZARD;
570 PropertySheet(&sheet);
573 int WINAPI WinMain(HINSTANCE _me,HINSTANCE hPrevInst,LPSTR lpszArgs, int nWinMode)
576 WNDCLASSEX wcl_background;
577 wcl_background.hInstance = me;
578 wcl_background.lpfnWndProc = WindowFunc;
579 wcl_background.lpszClassName= "SWFTools Install";
580 wcl_background.style = CS_HREDRAW | CS_VREDRAW;
581 wcl_background.hIcon = LoadIcon(NULL, IDI_APPLICATION);
582 wcl_background.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
583 wcl_background.hCursor = LoadCursor(NULL, IDC_ARROW);
584 wcl_background.lpszMenuName = NULL; //no menu
585 wcl_background.cbClsExtra = 0;
586 wcl_background.cbWndExtra = 0;
587 wcl_background.hbrBackground= CreateSolidBrush(RGB(0, 0, 128));
588 wcl_background.cbSize = sizeof(WNDCLASSEX);
590 HINSTANCE shell32 = LoadLibrary("shell32.dll");
592 MessageBox(0, "Could not load shell32.dll", "Install.exe", MB_OK);
595 f_SHGetSpecialFolderPath = (HRESULT (WINAPI*)(HWND,LPTSTR,int,BOOL))GetProcAddress(shell32, "SHGetSpecialFolderPathA");
596 if(!f_SHGetSpecialFolderPath) {
597 MessageBox(0, "Could not load shell32.dll", "Install.exe", MB_OK);
601 HRESULT coret = CoInitialize(NULL);
603 MessageBox(0, "Could not initialize COM interface", "Install.exe", MB_OK);
607 path_programfiles[0] = 0;
608 f_SHGetSpecialFolderPath(NULL, path_programfiles, CSIDL_PROGRAM_FILES, 0);
610 if(!RegisterClassEx(&wcl_background)) {
611 MessageBox(0, "Could not register window background class", "Install.exe", MB_OK);
615 HWND background = CreateWindow(wcl_background.lpszClassName, "Setup SWFTools",
617 GetSystemMetrics(SM_CXFULLSCREEN),
618 GetSystemMetrics(SM_CYFULLSCREEN),
620 (void*)"background");
623 MessageBox(0, "Could not create installation background window", "Install.exe", MB_OK);
627 ShowWindow(background, SW_SHOWMAXIMIZED);
628 SetForegroundWindow(background);
629 UpdateWindow(background);
631 logo = LoadBitmap(me, "SWFTOOLS");
633 install_path = getRegistryEntry("Software\\quiss.org\\swftools\\InstallPath");
634 if(!install_path || !install_path[0]) {
635 if(path_programfiles[0]) {
636 install_path = concatPaths(path_programfiles, "SWFTools");
638 install_path = "c:\\swftools\\";
643 InitCommonControls();
646 GetWindowRect(background, &r);
647 int xx = 320, yy = 200;
648 if(r.right - r.left > 320)
649 xx = r.right - r.left;
650 if(r.right - r.left > 200)
651 yy = r.bottom - r.top;
654 runPropertySheet(background);