+ if(message == WM_NOTIFY && (((LPNMHDR)lParam)->code == PSN_WIZFINISH)) {
+ if(!addRegistryEntries(install_path)) {
+ MessageBox(0, "Couldn't create Registry Entries", INSTALLER_NAME, 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);
+ }
+
+ char*uninstall_path = concatPaths(install_path, "uninstall.exe");
+
+ 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", INSTALLER_NAME, 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");
+ if(!CreateShortcut(pdf2swf_path, "pdf2swf", concatPaths(group, "pdf2swf.lnk"), 0, 0, 0, install_path) ||
+ !CreateShortcut(uninstall_path, "uninstall", concatPaths(group, "uninstall.lnk"), 0, 0, 0, install_path)) {
+ MessageBox(0, "Couldn't create start menu entry", INSTALLER_NAME, MB_OK);
+ return 1;
+ }
+ }
+ } else {
+ printf("not creating desktop/startmenu links\n");
+ }
+
+ char*uninstall_ini = concatPaths(install_path, "uninstall.ini");
+ addFile(uninstall_ini);
+ writeFileList(installedFiles, uninstall_ini);
+ }
+ return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_FINISH);
+}
+#endif
+
+#ifdef DEINSTALL
+
+void findfiles(char*path, int*pos, char*data, int len, char del)
+{
+ WIN32_FIND_DATA findFileData;
+ HANDLE hFind = FindFirstFile(concatPaths(path, "*"), &findFileData);
+ if(hFind == INVALID_HANDLE_VALUE)
+ return;
+ do {
+ if(findFileData.cFileName[0] == '.' &&
+ (findFileData.cFileName[0] == '.' || findFileData.cFileName == '\0'))
+ continue;
+ char*f = concatPaths(path, findFileData.cFileName);
+ if(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ findfiles(f, pos, data, len, del);
+ if(del) {
+ RemoveDirectory(f);
+ }
+ } else {
+ int l = strlen(f);
+
+ /* don't list the uninstaller as file- it's going to be removed *after*
+ everything else is done */
+ char*uninstaller="uninstall.exe";
+ int ll = strlen(uninstaller);
+ if(l>=ll) {
+ if(!strcasecmp(&f[l-ll],uninstaller)) {
+ continue;
+ }
+ }
+
+ if(data) {
+ if(*pos+l <= len) {
+ memcpy(&data[*pos], f, l);(*pos)+=l;
+ data[(*pos)++] = '\r';
+ data[(*pos)++] = '\n';
+ data[(*pos)] = 0;
+ }
+ } else {
+ (*pos) += l+2;
+ }
+ if(del) {
+ DeleteFile(f);
+ }
+ }
+ } while(FindNextFile(hFind, &findFileData));
+ FindClose(hFind);
+}
+
+static char*extrafiles = 0;
+
+BOOL CALLBACK PropertySheetFunc5(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
+ HWND dialog = GetParent(hwnd);
+ if(message == WM_INITDIALOG) {
+ SetDlgItemText(hwnd, IDC_INFO, "Ready to deinstall");
+ }
+ if(message == WM_NOTIFY && (((LPNMHDR)lParam)->code == PSN_WIZNEXT)) {
+
+ filelist_t* list = readFileList("uninstall.ini");
+ if(!list) {
+ list = readFileList(concatPaths(install_path, "uninstall.ini"));
+ if(!list) {
+ //Don't abort. If there's still something there, it'll be catched by the "extra files"
+ //functionality later
+ //MessageBox(0, "Couldn't determine installed files list- did you run uninstall twice?", INSTALLER_NAME, MB_OK);
+ //exit(-1);
+ }
+ }
+ filelist_t* l = list;
+ int num = 0;
+ while(l) {num++;l=l->next;}
+
+ PropSheet_SetWizButtons(dialog, 0);
+ SendMessage(dialog, PSM_CANCELTOCLOSE, 0, 0);
+ SetDlgItemText(hwnd, IDC_TITLE, "Uninstalling files...");
+ SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0, (LPARAM)MAKELONG(0,num));
+ num = 0;
+ l = list;
+ while(l) {
+ SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, num, 0);
+ if(l->type=='F')
+ DeleteFile(l->filename);
+ else if(l->type=='D')
+ RemoveDirectory(l->filename);
+ else if(l->type=='I')
+ /* skip- we will remove ourselves later */;
+ num++;l = l->next;
+ }
+
+ int len = 0;
+ findfiles(install_path, &len, 0, 0, 0);
+ if(len) {
+ extrafiles = malloc(len);
+ int pos = 0;
+ findfiles(install_path, &pos, extrafiles, len, 0);
+ } else {
+ PropSheet_RemovePage(dialog, 1, 0);
+ }
+ return 0;
+ }
+ return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_BACK|PSWIZB_NEXT);