resolve.c
来自「Dos6.0」· C语言 代码 · 共 664 行 · 第 1/2 页
C
664 行
#include <string.h>
#include "winenv.h"
#include "pro.h"
#include "ws.h"
#include "wsrc.h"
typedef unsigned char UCHAR;
#include <install.h>
#include <data.h>
#include <copy.h>
#include <global.h>
#include <file_io.h>
#include "lib\\common\\sulib.h"
extern char *GetDistribPrompt ( int iDiskNum );
void RebootSystem(void);
char gpszLoadBuf[MAX_RES]; // Used only in wsLoadsz() function for NULL case.
WORD fExit;
typedef struct {
LPSTR lpszPath;
BYTE cDisk;
} DISK, *PDISK;
extern struct MULT_FILES *gFiles;
extern void InsertDisk( int DskNum );
extern int iWillReboot;
/*
* Declared in towin.c, always contains the currect uninstall disk
* number (zero based)
*/
extern int iUninstallDiskNum;
extern void InitUninstallDisk ( int iUninstallDiskNum );
/*----------------------------------------------------------------------------*\
| fDialog(id,hwnd,fpfn) |
| |
| Description: |
| This function displays a dialog box and returns the exit code. |
| the function passed will have a proc instance made for it. |
| |
| this also handles special keyboard input by calling CheckSpecialKeys() |
| |
| |
| Arguments: |
| id resource id of dialog to display |
| hwnd parent window of dialog |
| fpfn dialog message function |
| |
| Returns: |
| exit code of dialog (what was passed to EndDialog) |
| |
\*----------------------------------------------------------------------------*/
int FAR fDialog(int id, HWND hwnd, FARPROC fpfn)
{
int result = 0;
MSG msg;
while (PeekMessage((LPMSG)&msg, NULL, WM_KEYFIRST, WM_MOUSELAST,
PM_NOYIELD|PM_REMOVE));
fpfn = MakeProcInstance(fpfn,hInstWS);
if (!fpfn)
goto ERR_EXIT;
result = DialogBox(hInstWS, MAKEINTRESOURCE(id), hwnd, fpfn);
FreeProcInstance(fpfn);
ERR_EXIT:
// wsHelp(HLP_NULL);
return result;
}
/*----------------------------------------------------------------------------*\
| fDialogWithlParam(int id, HWND hwnd, PARPROC fpfn, DWORD lParam) |
| |
| Description: |
| This function displays a dialog box and returns the exit code. |
| the function passed will have a proc instance made for it. |
| This function is equivelent to fDialog except it calls |
| DialogBoxParam(); to create the dialog so that init info |
| can be passed to the dislog proc at WM_INITDIALOG time. |
| |
| this also handles special keyboard input by calling CheckSpecialKeys() |
| |
| Arguments: |
| id resource id of dialog to display |
| hwnd parent window of dialog |
| fpfn dialog message function |
| lParam DWORD info that will become the lParam on the |
| WM_INITDIALOG message to the dialog proc. |
| |
| Returns: |
| exit code of dialog (what was passed to EndDialog) |
| |
\*----------------------------------------------------------------------------*/
int FAR fDialogWithlParam(int id, HWND hwnd, FARPROC fpfn, DWORD lParam)
{
int result = 0;
MSG msg;
// wsHelp(id);
while (PeekMessage((LPMSG)&msg, NULL, WM_KEYFIRST, WM_MOUSELAST,
PM_NOYIELD|PM_REMOVE));
fpfn = MakeProcInstance(fpfn,hInstWS);
if (!fpfn)
goto ERR_EXIT;
result = DialogBoxParam(hInstWS,MAKEINTRESOURCE(id),hwnd,fpfn,lParam);
FreeProcInstance(fpfn);
ERR_EXIT:
// wsHelp(HLP_NULL);
return result;
}
/***************************************************************************
*
*
* note:
* this uses a TASKMODAL dialog so no parent is needed.
*
* returns:
* TRUE user wants to exit
* FALSE doesn't want to exit
*
***************************************************************************/
BOOL PUBLIC QueryExit(HWND hwnd)
{
char buf[MAXSTR];
BOOL res;
HWND lHwnd;
// user press exit (implies aborted setup)
//
// first time setup, user is told that windows is not
// setup and given choice to continue
EnableExit(FALSE);
if ( hwnd )
lHwnd = hwnd;
else
lHwnd = GetActiveWindow();
if ( fExit & EF_NOEXIT )
return ( fDialog( DLG_BADDOSEXIT, lHwnd, wsBadDosExitDlg ) );
else
{
res = MessageBox(lHwnd,
wsLoadSz(IDS_EXITNOTSETUP, NULL, 0),
wsLoadSz(IDS_EXITCAP, buf, sizeof(buf)),
(MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2 | MB_SYSTEMMODAL))
== IDYES;
}
EnableExit(TRUE);
return res;
}
/*----------------------------------------------------------------------------*\
| wsLoadSz() |
| |
| Description: |
| Load a string from our resource file |
| |
| ids Id of string to load |
| pch buffer to place string, if NULL string will be placed in a |
| global buf |
| |
| Returns: |
| near pointer to loaded string |
| |
\*----------------------------------------------------------------------------*/
PSTR PUBLIC wsLoadSz(int ids, PSTR pch, int iBufLen)
{
if (pch == NULL)
{
pch = gpszLoadBuf;
LoadString(hInstWS,ids,pch,MAX_RES);
}
else
LoadString(hInstWS,ids,pch,iBufLen);
return pch;
}
void PUBLIC EnableExit(BOOL bEnable)
{
static int iCount = 1; // start out enabled
if (bEnable)
{
if (iCount < 1)
iCount++;
}
else
iCount--;
}
/* void PUBLIC wsDlgInit(HWND hDlg, WORD wWorkFlags);
*
* Function preforms various common dialog init duties, these include:
*
* Centering the dialog.
* Removing the Close menu.
* Flushing the keyboard queue.
*
* EMTRY: HWND hDlg - Handle to dialog window were initing.
*
* WORD wWorkFlags - 16 bits used to identify optional work needed
* for a particular dialog init.
*
* EXIT: None.
*
*/
void PUBLIC wsDlgInit(HWND hDlg, WORD wWorkFlags)
{
RECT rc;
MSG msg;
HANDLE hMenu;
/*
* Center the dialog.
*/
GetWindowRect(hDlg,&rc);
SetWindowPos(hDlg,NULL,
(GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2,
(GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 3,
0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
/*
* Remove Close menu if were asked to.
*/
if ( wWorkFlags & DLGINIT_REMOVE_CLOSE_MENU ) {
hMenu = GetSystemMenu(hDlg,FALSE);
if ( hMenu ) {
DeleteMenu(hMenu,SC_CLOSE,MF_BYCOMMAND);
DrawMenuBar(hDlg);
}
}
// Perform "flush" keyboard operation
// We retrieve and delete all keyboard messages placed in
// our application queue after calling CreateDialog. Doing so
// removes "strange" actions for impatient user, who pressed keys
// during creation of dialog.
while (PeekMessage((LPMSG)&msg, NULL, WM_KEYFIRST, WM_MOUSELAST,
PM_NOYIELD|PM_REMOVE));
}
/*----------------------------------------------------------------------------*\
| wsYield() |
| |
| Description: |
| Handle any messages in our queue, return when the queue is empty. |
| |
| Returns: |
| FALSE if a WM_QUIT message was encountered, TRUE otherwise |
|
|
| PAK 6/20/91 Added hwnd parameter to allow call to
| IsDialogMessage in order to process
| key messages such as 'Enter', 'Esc', et al.,
| when such processing is required. E.g.,
| when the Progress Dialog has a Cancel
| Button.
|
\*----------------------------------------------------------------------------*/
BOOL PUBLIC wsYield(HWND hwnd)
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// if ( msg.message == WM_KEYDOWN && msg.wParam == VK_F3 )
// PostMessage(hwndWS,WM_COMMAND,ID_EXITSETUP,(LONG)hwnd);
if ( !hwnd || !IsDialogMessage(hwnd, &msg) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return TRUE;
}
void PUBLIC AppQuit()
{
/*
* end the windows session, if are the boot shell
*/
#ifdef DEBUG
char szTmp[100];
wsprintf(szTmp,"DOSIIGUI Goodbye, iWillReboot = %i",iWillReboot);
FatalAppExit(0,szTmp);
#endif
if ( iWillReboot)
PostMessage(lpInstall->wHwndWinSetup,UM_CHILD_TERMINATED,EW_REBOOTSYSTEM,0L);
else
PostMessage(lpInstall->wHwndWinSetup,UM_CHILD_TERMINATED,0,0L);
DosExit(0); // dossetup goes bye bye via Int 21h/4Ch
}
char cDisk;
LPSTR szEdit;
/*----------------------------------------------------------------------------*\
| |
| wsCopyError() |
| |
| Handles errors, as the result of copying files. |
| |
| this may include net contention errors, in witch case the user must |
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?