home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Home
/
Visual_Home_Books_That_Work_1996.iso
/
dll
/
prompt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-12
|
4KB
|
127 lines
//****************************************************************************
// File: prompt.c
//
// Purpose: example DLL file to interface with Wise Installation System
//
// Functions: LibMain, Prompt, CheckType
//
//
// Programmer: John McMillan
//
//****************************************************************************
#include <windows.h>
#include <string.h>
#include "wisedll.h"
#include "resource.h"
#define MAX_PATH_LEN 128
BOOL FAR PASCAL PromptDlg(HWND, UINT, WPARAM, LPARAM);
char szPathName[MAX_PATH_LEN]; // Holds the pathname of the install dir
HINSTANCE hDllInst;
char cInstallType; // The type of installation
//***********************************************************************
// Function: LibMain
//
// Purpose: C function called from DLL entry point.
//
// Parameters: HINSTANCE hInst; DLL instance handle
// WORD wSeg; DLL data segment selector
// WORD cbHeapSize; DLL initial heap size in bytes
// LPSTR lpszCmdLine; DLL command line
//
// Returns: 1 is success, 0 fail DLL load
//
// Comments:
//
// History: Date Author Reason
//
//****************************************************************************
int CALLBACK LibMain(HINSTANCE hInst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
{
hDllInst = hInst;
return(1);
}
//***********************************************************************
// Function: Prompt
//
// Purpose: Prompt for the destination directory and type of install
//
// Parameters:
// LPDLLCALLPARAMS lpDllParams; Parameters from Wise
//
// Returns: TRUE if user canceled the install
//
// Comments:
//
// History: Date Author Reason
//
//****************************************************************************
BOOL __export CALLBACK Prompt(LPDLLCALLPARAMS lpDllParams)
{
BOOL bResult;
lstrcpy(szPathName,lpDllParams->lpszParam);
if (DialogBox(hDllInst,"PromptDlg",lpDllParams->hWnd,PromptDlg) == IDOK) {
bResult = FALSE;
lstrcpy(&lpDllParams->lpszRepName[lpDllParams->wCurrReps * lpDllParams->wRepNameWidth],"%WISE%");
lstrcpy(&lpDllParams->lpszRepStr[lpDllParams->wCurrReps * lpDllParams->wRepStrWidth],
szPathName);
lpDllParams->wCurrReps++;
lstrcpy(&lpDllParams->lpszRepName[lpDllParams->wCurrReps * lpDllParams->wRepNameWidth],"%TYPE%");
lpDllParams->lpszRepStr[lpDllParams->wCurrReps * lpDllParams->wRepStrWidth] = cInstallType;
lpDllParams->lpszRepStr[(lpDllParams->wCurrReps * lpDllParams->wRepStrWidth) + 1] = '\0';
lpDllParams->wCurrReps++;
} else {
bResult = TRUE;
}
return bResult;
}
BOOL __export CALLBACK PromptDlg(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG:
SetDlgItemText(hDlg,IDC_PATHNAME,szPathName);
CheckRadioButton(hDlg,IDC_COMPLETE_INSTALL,IDC_MINIMUM_INSTALL,
IDC_COMPLETE_INSTALL);
return (TRUE);
case WM_COMMAND:
if (wParam == IDOK || wParam == IDCANCEL) {
GetDlgItemText(hDlg,IDC_PATHNAME,szPathName,MAX_PATH_LEN);
if (IsDlgButtonChecked(hDlg,IDC_COMPLETE_INSTALL)) cInstallType = 'C';
if (IsDlgButtonChecked(hDlg,IDC_NETWORK_INSTALL)) cInstallType = 'N';
if (IsDlgButtonChecked(hDlg,IDC_MINIMUM_INSTALL)) cInstallType = 'M';
EndDialog(hDlg, wParam);
return (TRUE);
}
break;
}
return (FALSE);
}
BOOL __export CALLBACK CheckType(LPDLLCALLPARAMS lpDllParams)
{
WORD wCount;
BOOL bResult;
bResult = FALSE;
for (wCount = 0 ; (wCount < lpDllParams->wCurrReps) &&
(strcmp(&lpDllParams->lpszRepName[wCount * lpDllParams->wRepNameWidth],
"%TYPE%") != 0) ; wCount++) ;
if (wCount < lpDllParams->wCurrReps) {
if (lpDllParams->lpszRepStr[wCount * lpDllParams->wRepStrWidth] ==
lpDllParams->lpszParam[0]) {
bResult = TRUE;
}
}
return bResult;
return TRUE;
}