⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makezip.c

📁 有关zip的一个开发实例。主要包括图片和程序源代码。
💻 C
📖 第 1 页 / 共 2 页
字号:
         hSaveCursor = SetCursor(hHourGlass);         ShowCursor(TRUE);         if (fMakeSFX)            {            OFSTRUCT ofStrSrc;            OFSTRUCT ofStrDest;            HFILE hfSrcFile, hfDstFile;#ifndef WIN32            struct find_t ffblk;#else            WIN32_FIND_DATA ffblk;            HANDLE hfile;#endif            ZpOpt.fOffsets = TRUE; /* Force adjusting of offsets */            /* Get the path we are executing from */            GetModuleFileName(hInst, szTargetName,                  sizeof(szTargetName));            ptr = strrchr(szTargetName, '\\') + 1;            *ptr = '\0'; /* We've now got the path we are executing from */#ifdef WIN32            if (fMakeDosSFX)               lstrcat(szTargetName, "sfx16.dat");            else               lstrcat(szTargetName, "sfx32.dat");#else            lstrcat(szTargetName, "sfx16.dat");#endif#ifndef WIN32            if (_dos_findfirst(ZpZCL.lpszZipFN,                _A_NORMAL|_A_RDONLY|_A_ARCH,&ffblk) != 0)#else            if ((hfile = FindFirstFile(ZpZCL.lpszZipFN, &ffblk)) == INVALID_HANDLE_VALUE)#endif               {               hfSrcFile = LZOpenFile(szTargetName,                  &ofStrSrc, OF_READ);               if (hfSrcFile < 0)                  {#ifdef WIN32                  if (fMakeDosSFX)                     MessageBox (hWnd, "Can't find SFX16.DAT, continuing without making SFX exe.",                        "Can't find SFX16.DAT", MB_ICONINFORMATION | MB_OK);                  else                     MessageBox (hWnd, "Can't find SFX32.DAT, continuing without making SFX exe.",                        "Can't find SFX32.DAT", MB_ICONINFORMATION | MB_OK);#else                  MessageBox (hWnd, "Can't find SFX16.D1, continuing without making SFX exe.",                     "Can't find SFX16.DAT", MB_ICONINFORMATION | MB_OK);#endif                  }               else                  {                  hfDstFile = LZOpenFile(ZpZCL.lpszZipFN,                     &ofStrDest, OF_CREATE);                  LZCopy(hfSrcFile, hfDstFile);                  LZClose(hfSrcFile);                  LZClose(hfDstFile);                  }               }            else               {               int in, out;#ifdef WIN32               FindClose(hfile);#endif               /* Copy the prefix file over to the temp file */               hfSrcFile = LZOpenFile(szTargetName,                  &ofStrSrc, OF_READ);               if (hfSrcFile < 0)                  {#ifdef WIN32                  if (fMakeDosSFX)                     MessageBox (hWnd, "Can't find SFX16.DAT, continuing without making SFX exe.",                        "Can't find SFX16.DAT", MB_ICONINFORMATION | MB_OK);                  else                     MessageBox (hWnd, "Can't find SFX32.DAT, continuing without making SFX exe.",                        "Can't find SFX32.DAT", MB_ICONINFORMATION | MB_OK);#else                  MessageBox (hWnd, "Can't find SFX16.DAT, continuing without making SFX exe.",                     "Can't find SFX16.DAT", MB_ICONINFORMATION | MB_OK);#endif                  }               else                  {                  char buf[READ_WRITE_BUF];                  /* Get a temp file name and directory (Goes in directory                   * designated by tmp, temp or the current directory)                   */#ifdef WIN32                  GetTempPath(sizeof(szTargetName), szTargetName);                  GetTempFileName(szTargetName, "WIZ", 0, szTempFileName);#else                  GetTempFileName(0, "WIZ", 0, szTempFileName);#endif                  hfDstFile = LZOpenFile(szTempFileName,                     &ofStrDest, OF_CREATE);                  LZCopy(hfSrcFile, hfDstFile);                  LZClose(hfSrcFile);                  LZClose(hfDstFile);                  /* We've got the prefix moved over, now append the                   * archive file itself.                   */                  out = open(szTempFileName, O_RDWR | O_APPEND | O_BINARY );                  in = open(ZpZCL.lpszZipFN, O_RDONLY | O_BINARY);                  lseek(out, SEEK_CUR, SEEK_END);                  while (read(in, buf, READ_WRITE_BUF) > 0)                     {                     write(out, buf, READ_WRITE_BUF);                     }                  close(in);                  close(out);                  /* Copy the temp file back over the original file */                  hfSrcFile = LZOpenFile(szTempFileName,                     &ofStrSrc, OF_READ);                  if (hfSrcFile < 0)                     {                     MessageBox (hWnd, "Can't find temp file, continuing without making SFX exe.",                        "Can't find temp file", MB_ICONINFORMATION | MB_OK);                     }                  else                     {                     hfDstFile = LZOpenFile(ZpZCL.lpszZipFN,                        &ofStrDest, OF_CREATE);                     LZCopy(hfSrcFile, hfDstFile);                     LZClose(hfSrcFile);                     LZClose(hfDstFile);                     remove(szTempFileName);                     lstrcpy(szTempFileName, ZpZCL.lpszZipFN);                     if (lstrcmpi(&szTempFileName[lstrlen(ZpZCL.lpszZipFN) - 4],                        ".exe") != 0)                        {                        lstrcpy(&ZpZCL.lpszZipFN[lstrlen(ZpZCL.lpszZipFN) - 4],                           ".exe");                        rename(szTempFileName, ZpZCL.lpszZipFN);                        }                     }                  }               }            }         ZipSetOptions(ZpOpt);         ZipRetCode = ZipArchive(ZpZCL);         ShowCursor(FALSE);         SetCursor(hSaveCursor);         }      }      if ((toupper(lpumb->ofn.lpstrFile[0]) != 'A') &&          (toupper(lpumb->ofn.lpstrFile[0]) != 'B'))          {          lstrcpy(szTargetZipFile, lpumb->ofn.lpstrFile);          if ((lpchLast = lstrrchr(szTargetZipFile, '\\'))!=0)             {             *lpchLast = '\0';             }           else if ((lpchLast = lstrrchr(szTargetZipFile, ':'))!=0)             {             *(lpchLast+1) = '\0';             lstrcat(szTargetZipFile, "\\");             }           }        }      }else /* either real error or canceled */   {   DWORD dwExtdError = CommDlgExtendedError(); /* debugging */   if (dwExtdError != 0L) /* if not canceled then real error */      {      wsprintf (lpumb->szBuffer, szCantMakeZip, dwExtdError);      MessageBox (hWnd, lpumb->szBuffer, szAppName, MB_ICONINFORMATION | MB_OK);      }   else      {      RECT mRect;      WinAssert(hWndMain);      GetWindowRect(hWndMain, &mRect);      InvalidateRect(hWndMain, &mRect, TRUE);      SendMessage(hWndMain, WM_SIZE, SIZE_RESTORED,         MAKELONG(mRect.right-mRect.left, mRect.top-mRect.bottom));      UpdateWindow(hWndMain);      }   }/* Restore zip options flags */#ifdef WIN32ZpOpt.fPrivilege    = fPrivilege;#endifZpOpt.fExtra        = fExtra;ZpOpt.fRepair       = fRepair;ZpOpt.fVerbose      = fVerbose;ZpOpt.fForce        = fForce;ZpOpt.fSystem       = fSystem;ZpOpt.fVolume       = fVolume;ZpOpt.fNoDirEntries = fNoDirEntries;ZpOpt.fJunkDir      = fJunkDir;ZpOpt.fCRLF_LF      = fCRLF_LF;ZpOpt.fLF_CRLF      = fLF_CRLF;ZpOpt.fEncrypt      = fEncrypt;ZpOpt.fRecurse      = fRecurse;ZpOpt.fMove         = fMove;ZpOpt.fLatestTime   = fLatestTime;ZpOpt.fUpdate       = fUpdate;ZpOpt.fFreshen      = fFreshen;ZpOpt.fComment      = fComment;ZpOpt.fQuiet        = fQuiet;ZpOpt.fLevel        = fLevel;fMakeSFX              = fmakesfx;ZpOpt.fOffsets      = fOffsets;#ifdef WIN32fMakeDosSFX           = fdossfx;#endifif (hFileList)   {   GlobalUnlock(hFileList);   GlobalFree(hFileList);   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -