home *** CD-ROM | disk | FTP | other *** search
/ Visual Home / Visual_Home_Books_That_Work_1996.iso / dll / prompt.c < prev    next >
C/C++ Source or Header  |  1995-07-12  |  4KB  |  127 lines

  1. //****************************************************************************
  2. // File: prompt.c
  3. //
  4. // Purpose: example DLL file to interface with Wise Installation System
  5. //
  6. // Functions: LibMain, Prompt, CheckType
  7. //
  8. //
  9. // Programmer:  John McMillan
  10. //
  11. //****************************************************************************
  12.  
  13. #include <windows.h>
  14. #include <string.h>
  15. #include "wisedll.h"
  16. #include "resource.h"
  17.  
  18. #define MAX_PATH_LEN 128
  19.  
  20. BOOL FAR PASCAL PromptDlg(HWND, UINT, WPARAM, LPARAM);
  21.  
  22. char szPathName[MAX_PATH_LEN]; // Holds the pathname of the install dir
  23. HINSTANCE hDllInst;
  24. char cInstallType;  // The type of installation
  25.  
  26. //***********************************************************************
  27. // Function: LibMain
  28. //
  29. // Purpose: C function called from DLL entry point.
  30. //
  31. // Parameters: HINSTANCE hInst;   DLL instance handle
  32. //             WORD wSeg;         DLL data segment selector
  33. //             WORD cbHeapSize;   DLL initial heap size in bytes
  34. //             LPSTR lpszCmdLine; DLL command line
  35. //
  36. // Returns: 1 is success, 0 fail DLL load
  37. //
  38. // Comments:
  39. //
  40. // History:  Date       Author        Reason
  41. //
  42. //****************************************************************************
  43.  
  44. int CALLBACK LibMain(HINSTANCE hInst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  45. {
  46.    hDllInst = hInst;
  47.    return(1);
  48. }
  49.  
  50. //***********************************************************************
  51. // Function: Prompt
  52. //
  53. // Purpose: Prompt for the destination directory and type of install
  54. //
  55. // Parameters: 
  56. // LPDLLCALLPARAMS lpDllParams; Parameters from Wise
  57. //
  58. // Returns: TRUE if user canceled the install
  59. //
  60. // Comments:
  61. //
  62. // History:  Date       Author        Reason
  63. //
  64. //****************************************************************************
  65.  
  66. BOOL __export CALLBACK Prompt(LPDLLCALLPARAMS lpDllParams)
  67. {
  68.    BOOL bResult;
  69.  
  70.    lstrcpy(szPathName,lpDllParams->lpszParam);
  71.    if (DialogBox(hDllInst,"PromptDlg",lpDllParams->hWnd,PromptDlg) == IDOK) {
  72.       bResult = FALSE;
  73.       lstrcpy(&lpDllParams->lpszRepName[lpDllParams->wCurrReps * lpDllParams->wRepNameWidth],"%WISE%");
  74.       lstrcpy(&lpDllParams->lpszRepStr[lpDllParams->wCurrReps * lpDllParams->wRepStrWidth],
  75.          szPathName);
  76.       lpDllParams->wCurrReps++;
  77.       lstrcpy(&lpDllParams->lpszRepName[lpDllParams->wCurrReps * lpDllParams->wRepNameWidth],"%TYPE%");
  78.       lpDllParams->lpszRepStr[lpDllParams->wCurrReps * lpDllParams->wRepStrWidth] = cInstallType;
  79.       lpDllParams->lpszRepStr[(lpDllParams->wCurrReps * lpDllParams->wRepStrWidth) + 1] = '\0';
  80.       lpDllParams->wCurrReps++;
  81.    } else {
  82.       bResult = TRUE;
  83.    }
  84.    return bResult;
  85. }
  86.  
  87. BOOL __export CALLBACK PromptDlg(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  88. {
  89.    switch (message) {
  90.     case WM_INITDIALOG:
  91.       SetDlgItemText(hDlg,IDC_PATHNAME,szPathName);
  92.       CheckRadioButton(hDlg,IDC_COMPLETE_INSTALL,IDC_MINIMUM_INSTALL,
  93.          IDC_COMPLETE_INSTALL);
  94.       return (TRUE);
  95.     case WM_COMMAND:
  96.       if (wParam == IDOK || wParam == IDCANCEL) {
  97.          GetDlgItemText(hDlg,IDC_PATHNAME,szPathName,MAX_PATH_LEN);
  98.          if (IsDlgButtonChecked(hDlg,IDC_COMPLETE_INSTALL)) cInstallType = 'C';
  99.          if (IsDlgButtonChecked(hDlg,IDC_NETWORK_INSTALL)) cInstallType = 'N';
  100.          if (IsDlgButtonChecked(hDlg,IDC_MINIMUM_INSTALL)) cInstallType = 'M';
  101.          EndDialog(hDlg, wParam);
  102.          return (TRUE);
  103.       }
  104.       break;
  105.    }
  106.    return (FALSE);
  107. }
  108.  
  109. BOOL __export CALLBACK CheckType(LPDLLCALLPARAMS lpDllParams)
  110. {
  111.    WORD wCount;
  112.    BOOL bResult;
  113.    
  114.    bResult = FALSE;
  115.    for (wCount = 0 ; (wCount < lpDllParams->wCurrReps) &&
  116.       (strcmp(&lpDllParams->lpszRepName[wCount * lpDllParams->wRepNameWidth],
  117.               "%TYPE%") != 0) ; wCount++) ;
  118.    if (wCount < lpDllParams->wCurrReps) {
  119.       if (lpDllParams->lpszRepStr[wCount * lpDllParams->wRepStrWidth] == 
  120.           lpDllParams->lpszParam[0]) {
  121.          bResult = TRUE;
  122.       }
  123.    }
  124.    return bResult;
  125.    return TRUE;
  126. }
  127.