home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2001 January / VPR0101A.BIN / OLS / ZIP3J036 / zip3j036.lzh / zip32j / SRC / ZIP32J / ZIPAPI.C < prev    next >
C/C++ Source or Header  |  2000-10-29  |  3KB  |  112 lines

  1. /*
  2.     zipapi.c
  3.  
  4.         by Yoshioka Tsuneo(QWF00133@niftyserve.or.jp)
  5.         welcome any e-mail!!
  6.         You can use this file as Public Domain Software.
  7.         Copy,Edit,Re-distibute and for any purpose,you can use this file.
  8.  
  9. */
  10. #include "zipapi.h"
  11. #include <windows.h>
  12. #include <winbase.h>
  13. #include <stdio.h>
  14.  
  15. static HINSTANCE ZIP32DLLhLib=NULL;
  16. static int ZIP32DLLVersionItr=0;
  17. static char libname[1000]="";
  18.  
  19. void (WINAPI *ZpVersion)(ZpVer *) = NULL;
  20. int (WINAPI *ZpInit)(ZIPUSERFUNCTIONS *lpZipUserFunc) =NULL;
  21. BOOL (WINAPI *ZpSetOptions22)(ZPOPT22 Opts) =NULL;
  22. BOOL (WINAPI *ZpSetOptions23)(LPZPOPT23 Opts) =NULL;
  23. ZPOPT22 (WINAPI *ZpGetOptions22)(void) =NULL;
  24. ZPOPT23 (WINAPI *ZpGetOptions23)(void) =NULL;
  25. int(WINAPI *ZpArchive)(ZCL C) = NULL;
  26.  
  27.  
  28. char *ZIP32DLLLibName()
  29. {
  30.     return libname;
  31. }
  32. int ZIP32DLLVersion(void)
  33. {
  34.     return ZIP32DLLVersionItr;
  35. }
  36. int ZIP32DLLLoadLibrary(void)
  37. {
  38.     HINSTANCE hLib;
  39.     ZpVer ver;
  40.     char str[1000];
  41.  
  42.     if(ZIP32DLLhLib){return 0;}
  43.     hLib=LoadLibrary("ZIP32.DLL");
  44.     if(hLib){
  45.         strcpy(libname,"ZIP32.DLL");
  46.     }else{
  47.         hLib=LoadLibrary("IZIP32J.DLL");
  48.         if(hLib){
  49.             strcpy(libname,"IZIP32J.DLL");
  50.         }else{
  51.             MessageBox(NULL,"Can't load ZIP32.DLL","Error",MB_ICONEXCLAMATION);
  52.             return -1;
  53.         }
  54.     }
  55.  
  56.     ZIP32DLLhLib=hLib;
  57.     ZpVersion=GetProcAddress(hLib,"ZpVersion");
  58.     if(ZpVersion==NULL){
  59.         sprintf(str,"Can't GetProcAddress(%s,%s)",libname,"ZpVersion");
  60.         MessageBox(NULL,str,"Error",MB_ICONEXCLAMATION);
  61.         goto errorlabel;
  62.     }
  63.     ZpVersion(&ver);
  64.     ZIP32DLLVersionItr = ver.zip.major*256 + ver.zip.minor;
  65.     
  66.     ZpInit=GetProcAddress(hLib,"ZpInit");
  67.     if(ZpInit==NULL){
  68.         sprintf(str,"Can't GetProcAddress(%s,%s)",libname,"ZpInit");
  69.         MessageBox(NULL,str,"Error",MB_ICONEXCLAMATION);
  70.         goto errorlabel;
  71.     }
  72.     if(ZIP32DLLVersion() >= (2<<8)+3){
  73.         ZpSetOptions23=GetProcAddress(hLib,"ZpSetOptions");
  74.         ZpGetOptions23=GetProcAddress(hLib,"ZpGetOptions");
  75.         if(ZpSetOptions23==NULL || ZpGetOptions23==NULL){
  76.             sprintf(str,"Can't GetProcAddress(%s,%s)",libname,"ZpSetOptions(23)/ZpGetOptions(23)");
  77.             MessageBox(NULL,str,"Error",MB_ICONEXCLAMATION);
  78.             goto errorlabel;
  79.         }
  80.     }else{
  81.         ZpSetOptions22=GetProcAddress(hLib,"ZpSetOptions");
  82.         ZpGetOptions22=GetProcAddress(hLib,"ZpGetOptions");
  83.         if(ZpSetOptions22==NULL || ZpGetOptions22==NULL){
  84.             sprintf(str,"Can't GetProcAddress(%s,%s)",libname,"ZpSetOptions(22)/ZpGetOptions(22)");
  85.             MessageBox(NULL,str,"Error",MB_ICONEXCLAMATION);
  86.             goto errorlabel;
  87.         }
  88.     }
  89.     ZpArchive=GetProcAddress(hLib,"ZpArchive");
  90.     if(ZpArchive==NULL){
  91.         sprintf(str,"Can't GetProcAddress(%s,%s)",libname,"ZpArchive");
  92.         MessageBox(NULL,str,"Error",MB_ICONEXCLAMATION);
  93.         goto errorlabel;
  94.     }
  95.  
  96.     
  97.     return 0;
  98. errorlabel:
  99.     ZIP32DLLFreeLibrary();
  100.     return -1;
  101. }
  102. int ZIP32DLLFreeLibrary(void)
  103. {
  104.     if(ZIP32DLLhLib==NULL){return 0;}
  105.     ZpVersion=ZpInit=ZpSetOptions22=ZpSetOptions23=ZpGetOptions22=ZpGetOptions23=NULL;
  106.     FreeLibrary(ZIP32DLLhLib);
  107.     ZIP32DLLhLib = NULL;
  108.     return 0;
  109. }
  110.  
  111.  
  112.