X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=installer%2Finstaller.c;h=c5932d46a47d510740b590153e666c2740eab75b;hb=ee564c75cc677a6c5a0ae9a176dcb149cdc1d83a;hp=5d977d9a28f6f3a89283043e1d5f707307e5c7eb;hpb=e06725c02e06fd560e68499c93114e328d3fb33a;p=swftools.git diff --git a/installer/installer.c b/installer/installer.c index 5d977d9..c5932d4 100644 --- a/installer/installer.c +++ b/installer/installer.c @@ -28,6 +28,13 @@ #include "depack.h" #include "../config.h" //for swftools version +#include "../lib/os.h" //for registry functions + +static int config_forAllUsers = 0; +static int config_createLinks = 0; +static int config_createStartmenu = 1; +static int config_createDesktop = 1; + extern char*crndata; @@ -35,8 +42,12 @@ static char*install_path = "c:\\swftools\\"; static char pathBuf[1024]; static int do_abort = 0; -static HWND wnd_progress = 0; static HWND wnd_params = 0; +static HWND wnd_progress = 0; +static HWND wnd_finish = 0; +static HWND wnd_background = 0; + +static HBITMAP logo; #define USER_SETMESSAGE 0x7f01 @@ -60,23 +71,38 @@ struct params_data { HWND edit; HWND explore; }; +struct finish_data { + int width,height; + int ok; + char*text; + HWND installButton; + HWND check1; + HWND check2; +}; LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - printf("%08x, %d %08x %08x\n", hwnd, message, wParam, lParam); + //printf("%08x, %d %08x %08x\n", hwnd, message, wParam, lParam); /* in order for the delegation below to also work for WM_CREATE, we need to assign our window pointers *before* the CreateWindow returns, because that's when the WM_CREATE event is sent */ + if(message == WM_CREATE) { CREATESTRUCT*cs = ((LPCREATESTRUCT)lParam); if(cs->lpCreateParams && !strcmp((char*)cs->lpCreateParams, "params")) { wnd_params = hwnd; } - if(cs->lpCreateParams && !strcmp((char*)cs->lpCreateParams, "progress")) { + else if(cs->lpCreateParams && !strcmp((char*)cs->lpCreateParams, "progress")) { wnd_progress = hwnd; } + else if(cs->lpCreateParams && !strcmp((char*)cs->lpCreateParams, "finish")) { + wnd_finish = hwnd; + } + else if(cs->lpCreateParams && !strcmp((char*)cs->lpCreateParams, "background")) { + wnd_background = hwnd; + } } if(hwnd == 0) { @@ -94,6 +120,7 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara memset(&data, 0, sizeof(data)); data.text1 = "Installing SWFTools"; data.text2 = (char*)malloc(strlen(install_path)+250); + data.text3 = ""; sprintf(data.text2, "to %s", install_path); data.pos = 0; data.step = 1; @@ -108,6 +135,7 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara data.bar_posx = (data.width -data.bar_width)/2; data.bar_posy = 56; data.range = 50; + data.hwndButton = CreateWindow ( PROGRESS_CLASS, "Progress", @@ -117,26 +145,11 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara data.bar_width, data.bar_height, hwnd, /* Parent */ - (HMENU)1, + 0, cs->hInstance, NULL ); - data.wnd_text3 = CreateWindow ( - WC_EDIT, - "text3", - WS_CHILD | WS_VISIBLE | ES_READONLY | ES_CENTER, - data.bar_posx, - 72, - (rc.right - rc.left - data.bar_posx*2), - 20, - hwnd, /* Parent */ - (HMENU)1, - cs->hInstance, - NULL - ); - SendMessage(data.wnd_text3, WM_SETTEXT, 0, (LPARAM)""); - SendMessage(data.hwndButton, PBM_SETRANGE, 0, (LPARAM) MAKELONG(0,data.range)); SendMessage(data.hwndButton, PBM_SETSTEP, (WPARAM) data.step, 0); return 0; @@ -154,13 +167,21 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara RECT rc; /* A rectangle used during drawing */ hdc = GetDC(hwnd); - SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); + SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); GetTextMetrics(hdc, &tm); ReleaseDC(hwnd, hdc); - hdc = BeginPaint (hwnd, &ps); + /* + // draw logo + HDC memDc=CreateCompatibleDC(hdc); + SelectObject(memDc,logo); + BitBlt(hdc,0,0,406,93,memDc,0,0,SRCCOPY); + DeleteDC(memDc); + // / + */ + SetBkMode(hdc, TRANSPARENT); rc.top = 8; rc.left= 0; rc.right = data.width; rc.bottom = 24; @@ -178,6 +199,9 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara rc.top = 32; rc.left= 0; rc.right = data.width; rc.bottom = 48; DrawText(hdc, text, -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + + //rc.top = data.height-32; rc.left= 0; rc.right = data.width; rc.bottom = data.height; + //DrawText(hdc, data.text3, -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint (hwnd, &ps); return 0; @@ -201,20 +225,6 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara data.height = rc.bottom - rc.top; //EDITTEXT IDD_EDIT,68,8,72,12, ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP - HWND text = CreateWindow( - WC_STATIC, - "Select Installation Directory:", - WS_CHILD | WS_VISIBLE, - 32, - 16, - data.width-32*2, - 20, - hwnd, /* Parent */ - (HMENU)1, - cs->hInstance, - NULL - ); - data.edit = CreateWindow ( WC_EDIT, "EditPath", @@ -231,7 +241,7 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara data.explore = CreateWindow ( WC_BUTTON, - "Explore", + "Browse", WS_CHILD | WS_VISIBLE | WS_TABSTOP, data.width-32-64, 48, @@ -267,7 +277,20 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara return 0; } case WM_PAINT: { - return DefWindowProc(hwnd, message, wParam, lParam); + TEXTMETRIC tm; + HDC hdc; + PAINTSTRUCT ps; + RECT rc; + hdc = GetDC(hwnd); + SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); + GetTextMetrics(hdc, &tm); + ReleaseDC(hwnd, hdc); + hdc = BeginPaint (hwnd, &ps); + SetBkMode(hdc, TRANSPARENT); + rc.top = 32; rc.left= 16; rc.right = data.width-32*2; rc.bottom = 20; + DrawText(hdc, "Select Installation directory", -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + EndPaint (hwnd, &ps); + return 0; } case WM_COMMAND: { if((wParam&0xffff) == 0x9999) { @@ -296,13 +319,12 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara return 0; } else if((wParam&0xffff) == 0xabcd) { data.ok = 1; - DestroyWindow(wnd_params); + DestroyWindow(hwnd); return 0; } else if((wParam&0xffff) == 0x1234) { SendMessage(data.edit, WM_GETTEXT, sizeof(pathBuf), (LPARAM)&(pathBuf[0])); if(pathBuf[0]) { install_path = pathBuf; - printf("Path edited: now \"%s\"\n", install_path); } return 0; } @@ -310,7 +332,7 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara } case WM_KEYDOWN: { if(wParam == 0x49) { - DestroyWindow(wnd_params); + DestroyWindow(hwnd); } return 0; } @@ -324,6 +346,128 @@ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara default: return DefWindowProc(hwnd, message, wParam, lParam); } + } else if(hwnd == wnd_finish) { + static struct finish_data data; + switch(message) + { + case WM_CREATE: { + RECT rc; + CREATESTRUCT*cs = ((LPCREATESTRUCT)lParam); + GetClientRect (hwnd, &rc); + data.width = rc.right - rc.left; + data.height = rc.bottom - rc.top; + + data.text = malloc(strlen(install_path)+256); + sprintf(data.text, "SWFTools has been installed into directory\r\n%s\r\nsucessfully.", install_path); + + data.installButton = CreateWindow ( + WC_BUTTON, + "Finish", + WS_CHILD | WS_VISIBLE | WS_TABSTOP, + (data.width - 80)/2, + data.height - 32, + 80, + 32, + hwnd, + (HMENU)0xabce, + cs->hInstance, + NULL + ); + + if(config_createLinks) { + data.check1 = CreateWindow ( + WC_BUTTON, + "Create Desktop Shortcut", + WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_CHECKBOX, + 32, data.height - 96, + data.width-32*2, 32, + hwnd, (HMENU)0xabcf, cs->hInstance, NULL); + + data.check2 = CreateWindow ( + WC_BUTTON, + "Create Start Menu Entry", + WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_CHECKBOX, + 32, data.height - 64, + data.width-32*2, 32, + hwnd, (HMENU)0xabd0, cs->hInstance, NULL); + + SendDlgItemMessage(hwnd, 0xabcf, BM_SETCHECK, config_createStartmenu, 0); + SendDlgItemMessage(hwnd, 0xabd0, BM_SETCHECK, config_createDesktop, 0); + } + } + case WM_PAINT: { + TEXTMETRIC tm; + HDC hdc; + PAINTSTRUCT ps; + RECT rc; + hdc = GetDC(hwnd); + SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); + GetTextMetrics(hdc, &tm); + ReleaseDC(hwnd, hdc); + hdc = BeginPaint (hwnd, &ps); + SetBkMode(hdc, TRANSPARENT); + rc.left = 0; + rc.top = 10; + rc.right = data.width; + rc.bottom = data.height-40-32; + DrawText(hdc, data.text, -1, &rc, DT_CENTER | DT_VCENTER); + EndPaint (hwnd, &ps); + return 0; + + return DefWindowProc(hwnd, message, wParam, lParam); + } + case WM_COMMAND: { + if((wParam&0xffff) == 0xabce) { + data.ok = 1; + DestroyWindow(hwnd); + return 0; + } + if((wParam&0xffff) == 0xabcf) { + config_createDesktop = SendDlgItemMessage(hwnd, 0xabcf, BM_GETCHECK, 0, 0); + config_createDesktop^=1; + SendDlgItemMessage(hwnd, 0xabcf, BM_SETCHECK, config_createDesktop, 0); + return 0; + } + if((wParam&0xffff) == 0xabd0) { + config_createStartmenu = SendDlgItemMessage(hwnd, 0xabd0, BM_GETCHECK, 0, 0); + config_createStartmenu^=1; + SendDlgItemMessage(hwnd, 0xabd0, BM_SETCHECK, config_createStartmenu, 0); + return 0; + } + } + case WM_DESTROY: { + free(data.text);data.text = 0; + if(!data.ok) { + do_abort = 1; + PostQuitMessage(0); + } + wnd_finish = 0; + return DefWindowProc(hwnd, message, wParam, lParam); + } + } + } else if(hwnd == wnd_background) { + switch(message) + { + case WM_PAINT: { + HDC hdc; + PAINTSTRUCT ps; + RECT rc; + hdc = BeginPaint(hwnd, &ps); + SetBkMode(hdc, TRANSPARENT); + + HPEN pen = CreatePen(PS_SOLID, 2, RGB(255, 255, 0)); + HPEN oldPen = (HPEN)SelectObject(hdc, pen); + + MoveToEx(hdc, 10, 10, 0); + //LineTo(hdc, 100, 100); + + SelectObject(hdc, oldPen); + DeleteObject(pen); + + EndPaint(hwnd, &ps); + return 1; + } + } } return DefWindowProc(hwnd, message, wParam, lParam); } @@ -371,38 +515,61 @@ void myarchivestatus(int type, char*text) } } -static int regEnter(char*key,char*value) +int addRegistryEntries(char*install_dir) { - HKEY hkey; - int ret = 0; - ret = RegCreateKey(HKEY_LOCAL_MACHINE, key, &hkey); - if(ret != ERROR_SUCCESS) { - fprintf(stderr, "registry: CreateKey %s failed\n", key); - return 0; - } - ret = RegSetValue(hkey, NULL, REG_SZ, value, strlen(value)+1); - if(ret != ERROR_SUCCESS) { - fprintf(stderr, "registry: SetValue %s failed\n", key); - return 0; - } + int ret; + ret = setRegistryEntry("Software\\quiss.org\\swftools\\InstallPath", install_dir); + if(!ret) return 0; return 1; } -int addRegistryEntries(char*install_dir) +int CreateShortcut(char*path, char*description, char*filename, char*arguments, int iconindex, char*iconpath, char*workdir) { - int ret; - ret = regEnter("Software\\quiss.org\\swftools\\InstallPath", install_dir); - if(!ret) return 0; + WCHAR wszFilename[MAX_PATH]; + IShellLink *ps1 = NULL; + IPersistFile *pPf = NULL; + HRESULT hr; + hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (void*)&ps1); + if(FAILED(hr)) return 0; + hr = ps1->lpVtbl->QueryInterface(ps1, &IID_IPersistFile, (void **)&pPf); + if(FAILED(hr)) return 0; + hr = ps1->lpVtbl->SetPath(ps1, path); + if(FAILED(hr)) return 0; + hr = ps1->lpVtbl->SetDescription(ps1, description); + + if (arguments) { + hr = ps1->lpVtbl->SetArguments(ps1, arguments); + if(FAILED(hr)) return 0; + } + if (iconpath) { + hr = ps1->lpVtbl->SetIconLocation(ps1, iconpath, iconindex); + if (FAILED(hr)) return 0; + } + if (workdir) { + hr = ps1->lpVtbl->SetWorkingDirectory(ps1, workdir); + if (FAILED(hr)) return 0; + } + MultiByteToWideChar(CP_ACP, 0, filename, -1, wszFilename, MAX_PATH); + hr = pPf->lpVtbl->Save(pPf, wszFilename, TRUE); + if(FAILED(hr)) { + return 0; + } + pPf->lpVtbl->Release(pPf); + ps1->lpVtbl->Release(ps1); return 1; } + +static HRESULT (WINAPI *f_SHGetSpecialFolderPath)(HWND hwnd, LPTSTR lpszPath, int nFolder, BOOL fCreate); +static char path_startmenu[MAX_PATH]; +static char path_desktop[MAX_PATH]; + int WINAPI WinMain(HINSTANCE me,HINSTANCE hPrevInst,LPSTR lpszArgs, int nWinMode) { WNDCLASSEX wcl; - wcl.hInstance = me; - wcl.lpszClassName= "SWFTools-Installer"; wcl.lpfnWndProc = WindowFunc; + wcl.lpszClassName= "SWFTools-Install"; wcl.style = CS_HREDRAW | CS_VREDRAW; wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); wcl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); @@ -410,34 +577,111 @@ int WINAPI WinMain(HINSTANCE me,HINSTANCE hPrevInst,LPSTR lpszArgs, int nWinMode wcl.lpszMenuName = NULL; //no menu wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; - //wcl.hbrBackground= (HBRUSH) GetStockObject(DKGRAY_BRUSH); - //wcl.hbrBackground= (HBRUSH) GetStockObject (WHITE_BRUSH); - wcl.hbrBackground= (HBRUSH) GetStockObject (LTGRAY_BRUSH); - //wcl.hbrBackground= (HBRUSH) GetStockObject (GRAY_BRUSH); + wcl.hbrBackground= (HBRUSH)GetStockObject(LTGRAY_BRUSH); wcl.cbSize = sizeof(WNDCLASSEX); - if(!RegisterClassEx (&wcl)) { - return 0; + WNDCLASSEX wcl_text; + memcpy(&wcl_text, &wcl, sizeof(WNDCLASSEX)); + wcl_text.lpszClassName= "TextClass"; + wcl_text.hbrBackground = GetStockObject(HOLLOW_BRUSH); + + WNDCLASSEX wcl_background; + memcpy(&wcl_background, &wcl, sizeof(WNDCLASSEX)); + wcl_background.lpszClassName= "SWFTools Installer"; + wcl_background.hbrBackground= CreateSolidBrush(RGB(0, 0, 128)); + + HINSTANCE shell32 = LoadLibrary("shell32.dll"); + if(!shell32) { + MessageBox(0, "Could not load shell32.dll", "Install.exe", MB_OK); + return 1; + } + f_SHGetSpecialFolderPath = (HRESULT (WINAPI*)(HWND,LPTSTR,int,BOOL))GetProcAddress(shell32, "SHGetSpecialFolderPathA"); + if(!f_SHGetSpecialFolderPath) { + MessageBox(0, "Could not load shell32.dll", "Install.exe", MB_OK); + return 1; + } + + HRESULT ret = CoInitialize(NULL); + if(FAILED(ret)) { + MessageBox(0, "Could not initialize COM interface", "Install.exe", MB_OK); + 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); + } else { + f_SHGetSpecialFolderPath(NULL, path_desktop, CSIDL_DESKTOPDIRECTORY, 0); + f_SHGetSpecialFolderPath(NULL, path_startmenu, CSIDL_PROGRAMS, 0); + } + + if(!RegisterClassEx(&wcl)) { + MessageBox(0, "Could not register window class", "Install.exe", MB_OK); + return 1; + } + if(!RegisterClassEx(&wcl_background)) { + MessageBox(0, "Could not register window class 2", "Install.exe", MB_OK); + return 1; + } + + HWND background = CreateWindow(wcl_background.lpszClassName, "Setup SWFTools", + 0, 0, 0, + GetSystemMetrics(SM_CXFULLSCREEN), + GetSystemMetrics(SM_CYFULLSCREEN), + NULL, NULL, me, + (void*)"background"); + + if(!background) { + MessageBox(0, "Could not create installation background window", "Install.exe", MB_OK); + return 1; + } + + ShowWindow(background, SW_SHOWMAXIMIZED); + SetForegroundWindow(background); + UpdateWindow(background); + + RECT r = {0,0,0,0}; + GetWindowRect(background, &r); + int xx = 320, yy = 200; + if(r.right - r.left > 320) + xx = r.right - r.left; + if(r.right - r.left > 200) + yy = r.bottom - r.top; + + logo = LoadBitmap(me, "SWFTOOLS"); + + install_path = getRegistryEntry("Software\\quiss.org\\swftools\\InstallPath"); + if(!install_path || !install_path[0]) + install_path = "c:\\swftools\\"; + CoInitialize(0); InitCommonControls(); - - CreateWindow ( + + HWND installpath_window = CreateWindow( wcl.lpszClassName, /* Class name */ - "SWFTools Installer", /* Caption */ - WS_OVERLAPPEDWINDOW&(~WS_SIZEBOX), /* Style */ - CW_USEDEFAULT, /* Initial x (use default) */ - CW_USEDEFAULT, /* Initial y (use default) */ + "SWFTools Installer", /* Caption */ + /*WS_CHILD |*/ WS_CAPTION, + (xx-320)/2, /* Initial x */ + (yy-200)/2, /* Initial y */ 320, /* Initial x size */ 200, /* Initial y size */ - NULL, /* No parent window */ + background, /* No parent window */ NULL, /* No menu */ me, /* This program instance */ (void*)"params" /* Creation parameters */ ); + if(!installpath_window) { + MessageBox(background, "Could not create installation window", "Install.exe", MB_OK); + return 1; + } + ShowWindow (wnd_params, nWinMode); + SetFocus(wnd_params); + SetForegroundWindow(wnd_params); UpdateWindow (wnd_params); MSG msg; @@ -448,8 +692,10 @@ int WINAPI WinMain(HINSTANCE me,HINSTANCE hPrevInst,LPSTR lpszArgs, int nWinMode DispatchMessage(&msg); } - if(do_abort) - return 0; + if(do_abort) { + MessageBox(background, "Aborting Installation", "Error", MB_OK|MB_ICONERROR); + return 1; + } /*char buf[1024]; sprintf(buf, "Do you want me to install SWFTools into the directory %s now?", install_path); @@ -460,43 +706,88 @@ int WINAPI WinMain(HINSTANCE me,HINSTANCE hPrevInst,LPSTR lpszArgs, int nWinMode CreateWindow ( wcl.lpszClassName, /* Class name */ "Installing...", /* Caption */ - WS_OVERLAPPEDWINDOW&(~WS_SIZEBOX), /* Style */ - CW_USEDEFAULT, /* Initial x (use default) */ - CW_USEDEFAULT, /* Initial y (use default) */ + //WS_CHILD | WS_CAPTION, + WS_CAPTION, + (xx-260)/2, (yy-128)/2, 260, /* Initial x size */ 128, /* Initial y size */ - NULL, /* No parent window */ + background, /* No parent window */ NULL, /* No menu */ me, /* This program instance */ (void*)"progress" /* Creation parameters */ ); ShowWindow (wnd_progress, nWinMode); + SetFocus(wnd_progress); + SetForegroundWindow(wnd_progress); UpdateWindow (wnd_progress); - int success = unpack_archive(crndata, "C:\\swftools\\", myarchivestatus); + int success = unpack_archive(crndata, install_path, myarchivestatus); DestroyWindow(wnd_progress); while(wnd_progress) processMessages(); + if(do_abort) { + MessageBox(background, "Aborting Installation", "Error", MB_OK|MB_ICONERROR); + return 1; + } + + char* pdf2swf_path = concatPaths(install_path, "pdf2swf_gui.exe"); + FILE*fi = fopen(pdf2swf_path, "rb"); + if(fi) { + config_createLinks = 1; + fclose(fi); + } + + int h = config_createLinks?200:160; + CreateWindow ( + wcl.lpszClassName, /* Class name */ + "Finished", /* Caption */ + /*WS_CHILD |*/ WS_CAPTION, + //WS_OVERLAPPEDWINDOW&(~WS_SIZEBOX), /* Style */ + (xx-320)/2, (yy-h)/2, + 320, /* Initial x size */ + h, /* Initial y size */ + background, /* No parent window */ + NULL, /* No menu */ + me, /* This program instance */ + (void*)"finish" /* Creation parameters */ + ); + ShowWindow(wnd_finish, nWinMode); + SetFocus(wnd_finish); + SetForegroundWindow(wnd_finish); + UpdateWindow(wnd_finish); + + while(wnd_finish) + processMessages(); + if(do_abort) { + MessageBox(0, "Aborting Installation", "Error", MB_OK|MB_ICONERROR); + return 1; + } if(!addRegistryEntries(install_path)) { - success = 0; MessageBox(0, "Couldn't create Registry Entries", "SWFTools Install", MB_OK|MB_ICONERROR); + return 1; } - if(success) { - char buf[1024]; - sprintf(buf, "SWFTools Version %s has been installed into %s successfully", VERSION, install_path); - MessageBox(0, buf, "SWFTools Install", MB_OK|MB_ICONINFORMATION); - } else { - /* error will already have been notified by either myarchivestatus or some other - routine */ - /*sprintf(buf, "Installation failed\nLast message: %s", lastmessage); - ret = MessageBox(0, buf, "SWFTools Install", MB_OK|MB_ICONERROR);*/ + if(config_createLinks) { + if(config_createDesktop && path_desktop[0]) { + char* linkName = concatPaths(path_desktop, "pdf2swf.lnk"); + 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"); + 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; + } + } } exit(0); } - -