📄 wizmain.c
字号:
}else { char str[256]; wsprintf (str, DLL_VERSION_WARNING, UNZ_DLL_NAME); MessageBox (hWndMain, str, szAppName, MB_ICONSTOP | MB_OK); FreeUpMemory(); DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib); return 0; }#endif#endif#ifndef USE_ZIP_LIB#ifdef WIN32if (SearchPath( NULL, /* address of search path */ ZIP_DLL_NAME, /* address of filename */ NULL, /* address of extension */ PATH_MAX, /* size, in characters, of buffer */ szFullPath, /* address of buffer for found filename */ &ptr /* address of pointer to file component */ ) == 0)#elsehfile = OpenFile(ZIP_DLL_NAME, &ofs, OF_SEARCH);if (hfile == HFILE_ERROR)#endif { char str[256]; wsprintf (str, DLL_WARNING, ZIP_DLL_NAME); MessageBox((HWND)NULL, str, szAppName, MB_ICONSTOP | MB_OK); FreeUpMemory();#ifdef WIN32 DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib);#endif return 0; }#ifndef WIN32else lstrcpy(szFullPath, ofs.szPathName);_lclose(hfile);#endif#ifdef WIN32/* Now we'll check the zip dll version information */dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);if (dwVerInfoSize) { BOOL fRet, fRetName; char str[256]; LPSTR lpstrVffInfo; /* Pointer to block to hold info */ LPSTR lszVer = NULL; LPSTR lszVerName = NULL; UINT cchVer = 0; /* Get a block big enough to hold the version information */ hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize); lpstrVffInfo = GlobalLock(hMem); /* Get the version information */ GetFileVersionInfo(szFullPath, 0L, dwVerInfoSize, lpstrVffInfo); fRet = VerQueryValue(lpstrVffInfo, TEXT("\\StringFileInfo\\040904E4\\FileVersion"), (LPVOID)&lszVer, &cchVer); fRetName = VerQueryValue(lpstrVffInfo, TEXT("\\StringFileInfo\\040904E4\\CompanyName"), (LPVOID)&lszVerName, &cchVer); if (!fRet || !fRetName || (lstrcmpi(lszVer, ZIP_DLL_VERSION) != 0) || (lstrcmpi(lszVerName, COMPANY_NAME) != 0)) { wsprintf (str, DLL_VERSION_WARNING, ZIP_DLL_NAME); MessageBox((HWND)NULL, str, szAppName, MB_ICONSTOP | MB_OK); FreeUpMemory(); GlobalUnlock(hMem); GlobalFree(hMem); DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib); return 0; } /* free memory */ GlobalUnlock(hMem); GlobalFree(hMem); }else { char str[256]; wsprintf (str, DLL_VERSION_WARNING, ZIP_DLL_NAME); MessageBox((HWND)NULL, str, szAppName, MB_ICONSTOP | MB_OK); FreeUpMemory(); GlobalUnlock(hMem); GlobalFree(hMem); DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib); return 0; }#endif /* WIN32? */#endif/* Okay, now we know that the dll's exist, and have the proper version * information in them. We can go ahead and load them. */#ifndef USE_UNZIP_LIBhUnzipDll = LoadLibrary(UNZ_DLL_NAME);#ifndef WIN32if (hUnzipDll > HINSTANCE_ERROR)#elseif (hUnzipDll != NULL)#endif { (_DLL_UNZIP)Unz_SingleEntryPoint = (_DLL_UNZIP)GetProcAddress(hUnzipDll, "windll_unzip"); (_DLL_UNZVAL)Unz_Validate = (_DLL_UNZVAL)GetProcAddress(hUnzipDll, "UzpValidate"); if (!Unz_SingleEntryPoint || !Unz_Validate) { char str[256]; wsprintf (str, "Could not get entry point to %s", UNZ_DLL_NAME); MessageBox((HWND)NULL, str, szAppName, MB_ICONSTOP | MB_OK); FreeUpMemory();#ifdef WIN32 DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib);#endif return 0; } }else { char str[256]; wsprintf (str, "Could not load %s", UNZ_DLL_NAME); MessageBox((HWND)NULL, str, szAppName, MB_ICONSTOP | MB_OK); FreeUpMemory();#ifdef WIN32 DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib);#endif return 0; }#endif#ifndef USE_ZIP_LIBhZipDll = LoadLibrary(ZIP_DLL_NAME);#ifndef WIN32if (hZipDll > HINSTANCE_ERROR)#elseif (hZipDll != NULL)#endif { (_DLL_ZIP)ZipArchive = (_DLL_ZIP)GetProcAddress(hZipDll, "ZpArchive"); (ZIPSETOPTIONS)ZipSetOptions = (ZIPSETOPTIONS)GetProcAddress(hZipDll, "ZpSetOptions"); (ZIPGETOPTIONS)ZipGetOptions = (ZIPGETOPTIONS)GetProcAddress(hZipDll, "ZpGetOptions"); if (!ZipArchive || !ZipSetOptions || !ZipGetOptions) { char str[256]; wsprintf (str, "Could not get entry point to %s", ZIP_DLL_NAME); MessageBox((HWND)NULL, str, szAppName, MB_ICONSTOP | MB_OK); FreeUpMemory();#ifdef WIN32 DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib);#endif return 0; } }else { char str[256]; wsprintf (str, "Could not load %s", ZIP_DLL_NAME); MessageBox((HWND)NULL, str, szAppName, MB_ICONSTOP | MB_OK);#ifndef USE_UNZIP_LIB FreeLibrary(hUnzipDll);#endif FreeUpMemory();#ifdef WIN32 DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib);#endif return 0; }#endifGetPrivateProfileString(szAppName, szFirstUse, "Yes", lpumb->szBuffer, 256, szWiZIniFile);if ((fFirstUse = !lstrcmpi(lpumb->szBuffer, "Yes"))!=0) /* first time used as WiZ 4.0 */ {/* Flag that this is no longer the first time. */ WritePrivateProfileString(szAppName, szFirstUse, "No", szWiZIniFile);/* After first use, all options come out of WIZ.INI file */ }InitSoundOptions(); /* initialize sound options */wLBSelection = IDM_LB_DISPLAY; /* assume default is to display */hEditor = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (DWORD)EDIT_BUF_SIZE);if (!hEditor) { MessageBox((HWND)NULL, "Could not allocate memory", szAppName, MB_ICONSTOP | MB_OK);#ifndef USE_UNZIP_LIB FreeLibrary(hUnzipDll);#endif#ifndef USE_ZIP_LIB FreeLibrary(hZipDll);#endif FreeUpMemory();#ifdef WIN32 DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib);#endif return 0; }pszBuffer = (LPSTR)GlobalLock(hEditor);CreateButtonBar(hWndMain);#ifndef USE_ZIP_LIB(_ZIP_USER_FUNCTIONS)ZipInit = (_ZIP_USER_FUNCTIONS)GetProcAddress(hZipDll, "ZpInit");if (ZipInit == NULL) { MessageBox((HWND)NULL, "Cannot get address of ZpInit in Zip dll. Terminating...", szAppName, MB_ICONSTOP | MB_OK);#ifndef USE_UNZIP_LIB FreeLibrary(hUnzipDll);#endif FreeLibrary(hZipDll); FreeUpMemory();#ifdef WIN32 DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib);#endif return 0; }#endif if (!(*ZipInit)(lpZipUserFunctions)) { MessageBox((HWND)NULL, "Application functions not set up properly. Terminating...", szAppName, MB_ICONSTOP | MB_OK);#ifndef USE_UNZIP_LIB FreeLibrary(hUnzipDll);#endif#ifndef USE_UNZIP_LIB FreeLibrary(hZipDll);#endif FreeUpMemory();#ifdef WIN32 DestroyWindow(hSplashScreen); FreeLibrary(hRTFLib);#endif return 0; }#ifndef WIN32if (_fstrlen(lpCmdLine)) /* if filename passed on start-up */#elseif (strlen(lpCmdLine)) /* if filename passed on start-up */#endif { if ((lstrcmpi(&lpCmdLine[lstrlen(lpCmdLine) - 4], ".zip") != 0) && (lstrcmpi(&lpCmdLine[lstrlen(lpCmdLine) - 4], ".exe") != 0)) { lstrcat(lpCmdLine, ".zip"); } if (lstrcmpi(&lpCmdLine[lstrlen(lpCmdLine) - 8], ".zip.zip") == 0) lpCmdLine[lstrlen(lpCmdLine) - 4] = '\0'; if ((ofretval = OpenFile(lpCmdLine, &lpumb->of, OF_EXIST)) >= 0) { lstrcpy(lpumb->szFileName, lpumb->of.szPathName); /* save file name */ /* If valid filename change dir to where it lives */ GetArchiveDir(lpumb->szDirName); /* get archive dir. in ANSI char set */ if (uf.fUnzipToZipDir || /* unzipping to same directory as archive */ szUnzipToDirName[0] == '\0') /* or no default */ { /* take only path portion */ lstrcpy(szUnzipToDirName, lpumb->szDirName); } lstrcpy(lpumb->szBuffer, lpumb->szDirName); DlgDirList(hWndMain, lpumb->szBuffer, 0, 0, 0); /* go to where archive lives */ } else /* bad file name */ { wsprintf (lpumb->szBuffer, "Cannot open %s", lpCmdLine); MessageBox (NULL, lpumb->szBuffer, szAppName, MB_ICONINFORMATION | MB_OK); lpumb->szFileName[0] = '\0'; /* pretend filename doesn't exist */ lpumb->szDirName[0] = '\0'; /* pretend archive dir. doesn't exist */ } }if (uf.fUnzipToZipDir || /* unzipping to same directory as archive */ szUnzipToDirName[0] == '\0') /* or no default */ { char szLaunchPath[PATH_MAX];#ifdef WIN32 GetCurrentDirectory(PATH_MAX, (LPTSTR)szLaunchPath);#else getcwd(szLaunchPath, PATH_MAX); /* get current drive and directory */#endif lstrcpy(lpumb->szDirName, szLaunchPath); lstrcpy(szUnzipToDirName, lpumb->szDirName); }UpdateListBox();UpdateButtons();/* Enable/Disable buttons */WinAssert(hSelectAll);EnableWindow( hSelectAll, FALSE);WinAssert(hDeselectAll);EnableWindow( hDeselectAll, FALSE);WinAssert(hSelectPattern);EnableWindow( hSelectPattern, FALSE);/* Throw up splash screen */#ifdef WIN32second = (GetTickCount()/1000) + 5;while ((GetTickCount()/1000) <= second);DestroyWindow(hSplashScreen);#endifSizeWindow();WinAssert(hWndMain);ShowWindow(hWndMain, nCmdShow);ShowWindow(hWndList, SW_SHOW);ShowWindow(hWndStatic, SW_SHOW);ShowWindow(hWndEdit, SW_SHOW);/* On first use, throw up About box, saying what WiZ is, etc. */if (fFirstUse) { PostMessage(hWndMain, WM_COMMAND, IDM_ABOUT, 0L); }hHelpCursor = LoadCursor(hInstance, "HelpCursor");while ( GetMessage(&lpumb->msg, 0, 0, 0) ) { if (hPatternSelectDlg == 0 || /* Pattern select dialog is non-modal */ !IsDialogMessage(hPatternSelectDlg, &lpumb->msg)) { /* What we are doing here is to intercept the right mouse button up command if it is being sent to Wiz's main window, or any of it's child windows - such as the list box or edit box. We then process the WM_RBUTTONUP message for either the listbox or the editbox as though it were sent to the main window. Another way to do this would be to subclass both those windows, but this seems a lot easier, with less code involved. This would also be much easier if we were only dealing with 32 bit windows, but we also have to deal with the 16 bit version. */ if ((lpumb->msg.message == WM_RBUTTONUP) && ((lpumb->msg.hwnd == hWndStatic) || (lpumb->msg.hwnd == hWndEdit) || (lpumb->msg.hwnd == hWndList))) { lpumb->msg.hwnd = hWndMain; DispatchMessage(&lpumb->msg); } else if ( !TranslateAccelerator(hWndMain, hAccTable, &lpumb->msg) ) { TranslateMessage(&lpumb->msg); DispatchMessage(&lpumb->msg); } } }/* Don't turn on compiler aliasing or C7 will move *//* the following assignment after the GlobalFree() *//* which contains the memory for pumb! */i = (int)lpumb->msg.wParam;FreeUpMemory();#ifndef USE_UNZIP_LIBFreeLibrary(hZipDll);#endif#ifndef USE_ZIP_LIBFreeLibrary(hUnzipDll);#endif#ifdef WIN32FreeLibrary(hRTFLib);#endifreturn i;}int WINAPI GetReplaceDlgRetVal(char *filename){FARPROC lpfnprocReplace;int ReplaceDlgRetVal; /* replace dialog return value */ShowCursor(FALSE); /* turn off cursor */SetCursor(hSaveCursor); /* restore the cursor */lpfnprocReplace = MakeProcInstance(ReplaceProc, hInst);ReplaceDlgRetVal = DialogBoxParam(hInst, "Replace", hWndMain, lpfnprocReplace, (DWORD)(LPSTR)filename);#ifndef WIN32FreeProcInstance(lpfnprocReplace);#endifhSaveCursor = SetCursor(hHourGlass);ShowCursor(TRUE);return ReplaceDlgRetVal;}void FreeUpMemory(void){if (hStrings) { GlobalUnlock(hStrings); GlobalFree(hStrings); }if (hDCL) { GlobalUnlock(hDCL); GlobalFree(hDCL); }if (hEditor) { GlobalUnlock(hEditor); GlobalFree(hEditor); }if (hUF) { GlobalUnlock(hUF); GlobalFree(hUF); }if (hZUF) { GlobalUnlock(hZUF); GlobalFree(hZUF); }}#ifdef WIN32BOOL IsNT(VOID){if(dwPlatformId != 0xFFFFFFFF) return dwPlatformId;else/* note: GetVersionEx() doesn't exist on WinNT 3.1 */ { if(GetVersion() < 0x80000000) { (BOOL)dwPlatformId = TRUE; } else { (BOOL)dwPlatformId = FALSE; } }return dwPlatformId;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -