+ if(size < 1024)
+ sprintf(dest, "%s%d Bytes", msg, size);
+ else if(size < 1048576l)
+ sprintf(dest, "%s%.2f Kb", msg, size/1024.0);
+ else if(size < 1073741824l)
+ sprintf(dest, "%s%.2f Mb", msg, size/1048576.0);
+ else if(size < 1099511627776ll)
+ sprintf(dest, "%s%.2f Gb", msg, size/1073741824.0);
+ else
+ sprintf(dest, "%s%.2f Tb", msg, size/1125899906842624.0);
+}
+
+BOOL CALLBACK PropertySheetFunc3(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
+ HWND dialog = GetParent(hwnd);
+ if(message == WM_INITDIALOG) {
+ SetDlgItemText(hwnd, IDC_INFO, "Ready to install");
+
+ char buf[256];
+ print_space(buf, "Space required: ", crn_decompressed_size);
+ SetDlgItemText(hwnd, IDC_SPACE1, buf);
+ ULARGE_INTEGER available,total,totalfree;
+ available.QuadPart=0;
+ total.QuadPart=0;
+ totalfree.QuadPart=0;
+ GetDiskFreeSpaceEx(install_path, &available, &total, &totalfree);
+ print_space(buf, "Space available: ", available.QuadPart);
+ SetDlgItemText(hwnd, IDC_SPACE2, buf);
+ }
+ if(message == WM_NOTIFY && (((LPNMHDR)lParam)->code == PSN_WIZNEXT)) {
+ SetDlgItemText(hwnd, IDC_SPACE1, "");
+ SetDlgItemText(hwnd, IDC_SPACE2, "");
+ PropSheet_SetWizButtons(dialog, 0);
+ SendMessage(dialog, PSM_CANCELTOCLOSE, 0, 0); //makes wine display a warning
+ SetDlgItemText(hwnd, IDC_TITLE, "Installing files...");
+ statuswnd = hwnd;
+ SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0, (LPARAM)MAKELONG(0,40));
+ progress_pos = 0;
+ SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, progress_pos, 0);
+ int success = unpack_archive(crndata, crndata_len, install_path, PropertyArchiveStatus);
+ if(!success) {
+ MessageBox(0, "Couldn't extract all installation files", "SWFTools Install", MB_OK|MB_ICONERROR);
+ do_abort=1;
+ exit(1);
+ }
+ return 0;
+ }
+ return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_BACK|PSWIZB_NEXT);
+}
+
+static HRESULT (WINAPI *f_SHGetSpecialFolderPath)(HWND hwnd, LPTSTR lpszPath, int nFolder, BOOL fCreate);
+
+BOOL CALLBACK PropertySheetFunc4(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
+ if(message == WM_INITDIALOG) {
+ pdf2swf_path = concatPaths(install_path, "pdf2swf_gui.exe");
+ FILE*fi = fopen(pdf2swf_path, "rb");
+ if(fi) {
+ printf("a GUI program exists, creating desktop/startmenu links\n");
+ config_createLinks = 1;
+ fclose(fi);
+ }
+ if(!config_createLinks) {
+ SendDlgItemMessage(hwnd, IDC_STARTMENU, SW_HIDE, 0, 0);
+ SendDlgItemMessage(hwnd, IDC_DESKTOP, SW_HIDE, 0, 0);
+ }
+
+ SendDlgItemMessage(hwnd, IDC_STARTMENU, BM_SETCHECK, config_createStartmenu, 0);
+ SendDlgItemMessage(hwnd, IDC_DESKTOP, BM_SETCHECK, config_createStartmenu, 0);
+ }
+ if(message == WM_COMMAND) {
+ if((wParam&0xffff) == IDC_STARTMENU) {
+ config_createStartmenu = SendDlgItemMessage(hwnd, IDC_STARTMENU, BM_GETCHECK, 0, 0);
+ config_createStartmenu^=1;
+ SendDlgItemMessage(hwnd, IDC_STARTMENU, BM_SETCHECK, config_createStartmenu, 0);
+ return 0;
+ }
+ if((wParam&0xffff) == IDC_DESKTOP) {
+ config_createDesktop = SendDlgItemMessage(hwnd, IDC_DESKTOP, BM_GETCHECK, 0, 0);
+ config_createDesktop^=1;
+ SendDlgItemMessage(hwnd, IDC_DESKTOP, BM_SETCHECK, config_createDesktop, 0);
+ return 0;
+ }
+ }
+
+ if(message == WM_NOTIFY && (((LPNMHDR)lParam)->code == PSN_WIZFINISH)) {
+ if(!addRegistryEntries(install_path)) {
+ MessageBox(0, "Couldn't create Registry Entries", "SWFTools Install", MB_OK|MB_ICONERROR);
+ return 1;
+ }
+
+ char mypath[MAX_PATH];
+ path_startmenu[0] = 0;
+ path_desktop[0] = 0;
+ if(config_forAllUsers) {
+ f_SHGetSpecialFolderPath(NULL, path_desktop, CSIDL_COMMON_DESKTOPDIRECTORY, 0);
+ f_SHGetSpecialFolderPath(NULL, path_startmenu, CSIDL_COMMON_PROGRAMS, 0);
+ }
+ /* get local program/desktop directory- this is both for forAllUsers=0 as well
+ as a fallback if the above didn't return any paths */
+ if(!path_startmenu[0]) {
+ f_SHGetSpecialFolderPath(NULL, path_startmenu, CSIDL_PROGRAMS, 0);
+ }
+ if(!path_desktop[0]) {
+ f_SHGetSpecialFolderPath(NULL, path_desktop, CSIDL_DESKTOPDIRECTORY, 0);
+ }
+
+ if(config_createLinks) {
+ if(config_createDesktop && path_desktop[0]) {
+ char* linkName = concatPaths(path_desktop, "pdf2swf.lnk");
+ printf("Creating desktop link %s -> %s\n", linkName, pdf2swf_path);
+ if(!CreateShortcut(pdf2swf_path, "pdf2swf", linkName, 0, 0, 0, install_path)) {
+ MessageBox(0, "Couldn't create desktop shortcut", "Install.exe", MB_OK);
+ return 1;
+ }
+ }
+ if(config_createStartmenu && path_startmenu[0]) {
+ char* group = concatPaths(path_startmenu, "pdf2swf");
+ CreateDirectory(group, 0);
+ char* linkName = concatPaths(group, "pdf2swf.lnk");
+ printf("Creating %s -> %s\n", linkName, pdf2swf_path);
+ if(!CreateShortcut(pdf2swf_path, "pdf2swf", linkName, 0, 0, 0, install_path)) {
+ MessageBox(0, "Couldn't create start menu entry", "Install.exe", MB_OK);
+ return 1;
+ }
+ }
+ } else {
+ printf("not creating desktop/startmenu links\n");
+ }
+ }
+ return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_FINISH);