Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 1st, 2012  |  syntax: None  |  size: 8.92 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Attempted to read or write protected memory when accessing dll
  2. System.AccessViolationException: Attempted to read or write protected memory.
  3. This is often an indication that other memory is corrupt.
  4. at projectName.clsName.ZpArchive(ZCL& zcl, ZPOPT& zopts)
  5. at projectName.clsName.functionName() in <location>:<line>
  6.        
  7. //ZCL Structures
  8. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  9. protected struct ZCL
  10. {
  11.     public int argc;                  /* Count of files to zip */
  12.     [MarshalAs(UnmanagedType.LPStr)]
  13.     public string fzname;             /* name of archive to create/update */
  14.     public string[] zipnames;         /* zip file name */
  15.     [MarshalAs(UnmanagedType.LPStr)]
  16.     public string fzlist;             /* name of archive to create/update */
  17. }
  18.  
  19. //ZPOPT Structures
  20. [ StructLayout( LayoutKind.Sequential )]
  21.             protected struct ZPOPT
  22.             {
  23.                   [MarshalAs(UnmanagedType.LPTStr)]
  24.                   public string Date;                             // US Date (8 Bytes Long) "12/31/98"?
  25.                   [MarshalAs(UnmanagedType.LPTStr)]
  26.                   public string szRootDir;                  // Root Directory Pathname (Up To 256 Bytes Long)
  27.                   [MarshalAs(UnmanagedType.LPTStr)]
  28.                   public string szTempDir;                  // Temp Directory Pathname (Up To 256 Bytes Long)
  29.                   public int fTemp;                         // 1 If Temp dir Wanted, Else 0
  30.                   public int fSuffix;                             // Include Suffixes (Not Yet Implemented!)
  31.                   public int fEncrypt;                            // 1 If Encryption Wanted, Else 0
  32.                   public int fSystem;                             // 1 To Include System/Hidden Files, Else 0
  33.                   public int fVolume;                             // 1 If Storing Volume Label, Else 0
  34.                   public int fExtra;                                    // 1 If Excluding Extra Attributes, Else 0
  35.                   public int fNoDirEntries;                 // 1 If Ignoring Directory Entries, Else 0
  36.                   public int fExcludeDate;                  // 1 If Excluding Files Earlier Than Specified Date, Else 0
  37.                   public int fIncludeDate;                  // 1 If Including Files Earlier Than Specified Date, Else 0
  38.                   public int fVerbose;                            // 1 If Full Messages Wanted, Else 0
  39.                   public int fQuiet;                                    // 1 If Minimum Messages Wanted, Else 0
  40.                   public int fCRLF_LF;                      // 1 If Translate CR/LF To LF, Else 0
  41.                   public int fLF_CRLF;                      // 1 If Translate LF To CR/LF, Else 0
  42.                   public int fJunkDir;                            // 1 If Junking Directory Names, Else 0
  43.                   public int fGrow;                               // 1 If Allow Appending To Zip File, Else 0
  44.                   public int fForce;                                    // 1 If Making Entries Using DOS File Names, Else 0
  45.                   public int fMove;                               // 1 If Deleting Files Added Or Updated, Else 0
  46.                   public int fDeleteEntries;                // 1 If Files Passed Have To Be Deleted, Else 0
  47.                   public int fUpdate;                             // 1 If Updating Zip File-Overwrite Only If Newer, Else 0
  48.                   public int fFreshen;                            // 1 If Freshing Zip File-Overwrite Only, Else 0
  49.                   public int fJunkSFX;                      // 1 If Junking SFX Prefix, Else 0
  50.                   public int fLatestTime;                   // 1 If Setting Zip File Time To Time Of Latest File In Archive, Else 0
  51.                   public int fComment;                      // 1 If Putting Comment In Zip File, Else 0
  52.                   public int fOffsets;                            // 1 If Updating Archive Offsets For SFX Files, Else 0
  53.                   public int fPrivilege;                    // 1 If Not Saving Privileges, Else 0
  54.                   public int fEncryption;                   // Read Only Property!!!
  55.                   public int fRecurse;                            // 1 (-r), 2 (-R) If Recursing Into Sub-Directories, Else 0
  56.                   public int fRepair;                             // 1 = Fix Archive, 2 = Try Harder To Fix, Else 0
  57.                   public byte flevel;                             // Compression Level - 0 = Stored 6 = Default 9 = Max
  58.                   [MarshalAs(UnmanagedType.LPTStr)]
  59.                   public string fSplitSize;                       //Null for no spliting size
  60.                   //addition for ZCL
  61.                   public int m_CountFile;                         //For total file on backup file.
  62.             }
  63.  
  64. //Import Dll:
  65. [DllImport("zip32.dll", SetLastError=true)]            
  66. protected static extern int ZpArchive(ref ZCL zcl,ref ZPOPT zopts);
  67.        
  68. //set the zip options
  69.               m_zopts = CreateZPOPTOptions();
  70.  
  71.               ZCL zcl = new ZCL();
  72.               zcl.argc = m_CountFile; //Total file
  73.               zcl.fzname = m_ZipFileName;
  74.               zcl.zipnames = m_FilesToZip;
  75.               zcl.fzlist = null;
  76.  
  77.               //zip the files
  78.               try
  79.               {
  80.                   ret = ZpArchive(ref zcl,ref m_zopts);
  81.               }
  82.               catch(Exception e)
  83.               {
  84.                     //<catch>
  85.               }
  86.        
  87. typedef struct {        /* zip options */
  88. LPSTR Date;             /* Date to include after */
  89. LPSTR szRootDir;        /* Directory to use as base for zipping */
  90. LPSTR szTempDir;        /* Temporary directory used during zipping */
  91. BOOL fTemp;             /* Use temporary directory '-b' during zipping */
  92. BOOL fSuffix;           /* include suffixes (not implemented) */
  93. BOOL fEncrypt;          /* encrypt files */
  94. BOOL fSystem;           /* include system and hidden files */
  95. BOOL fVolume;           /* Include volume label */
  96. BOOL fExtra;            /* Exclude extra attributes */
  97. BOOL fNoDirEntries;     /* Do not add directory entries */
  98. BOOL fExcludeDate;      /* Exclude files newer than specified date */
  99. BOOL fIncludeDate;      /* Include only files newer than specified date */
  100. BOOL fVerbose;          /* Mention oddities in zip file structure */
  101. BOOL fQuiet;            /* Quiet operation */
  102. BOOL fCRLF_LF;          /* Translate CR/LF to LF */
  103. BOOL fLF_CRLF;          /* Translate LF to CR/LF */
  104. BOOL fJunkDir;          /* Junk directory names */
  105. BOOL fGrow;             /* Allow appending to a zip file */
  106. BOOL fForce;            /* Make entries using DOS names (k for Katz) */
  107. BOOL fMove;             /* Delete files added or updated in zip file */
  108. BOOL fDeleteEntries;    /* Delete files from zip file */
  109. BOOL fUpdate;           /* Update zip file--overwrite only if newer */
  110. BOOL fFreshen;          /* Freshen zip file--overwrite only */
  111. BOOL fJunkSFX;          /* Junk SFX prefix */
  112. BOOL fLatestTime;       /* Set zip file time to time of latest file in it */
  113. BOOL fComment;          /* Put comment in zip file */
  114. BOOL fOffsets;          /* Update archive offsets for SFX files */
  115. BOOL fPrivilege;        /* Use privileges (WIN32 only) */
  116. BOOL fEncryption;       /* TRUE if encryption supported, else FALSE.
  117.                            this is a read only flag */
  118. LPSTR szSplitSize;      /* This string contains the size that you want to
  119.                            split the archive into. i.e. 100 for 100 bytes,
  120.                            2K for 2 k bytes, where K is 1024, m for meg
  121.                            and g for gig. If this string is not NULL it
  122.                            will automatically be assumed that you wish to
  123.                            split an archive. */
  124. LPSTR szIncludeList;    /* Pointer to include file list string (for VB) */
  125. long IncludeListCount;  /* Count of file names in the include list array */
  126. char **IncludeList;     /* Pointer to include file list array. Note that the last
  127.                            entry in the array must be NULL */
  128. LPSTR szExcludeList;    /* Pointer to exclude file list (for VB) */
  129. long ExcludeListCount;  /* Count of file names in the include list array */
  130. char **ExcludeList;     /* Pointer to exclude file list array. Note that the last
  131.                            entry in the array must be NULL */
  132. int  fRecurse;          /* Recurse into subdirectories. 1 => -r, 2 => -R */
  133. int  fRepair;           /* Repair archive. 1 => -F, 2 => -FF */
  134. char fLevel;            /* Compression level (0 - 9) */
  135. } ZPOPT, _far *LPZPOPT;
  136.  
  137. typedef struct {
  138.   int  argc;            /* Count of files to zip */
  139.   LPSTR lpszZipFN;      /* name of archive to create/update */
  140.   char **FNV;           /* array of file names to zip up */
  141.   LPSTR lpszAltFNL;     /* pointer to a string containing a list of file
  142.                            names to zip up, separated by whitespace. Intended
  143.                            for use only by VB users, all others should set this
  144.                            to NULL. */
  145. } ZCL, _far *LPZCL;
  146.        
  147. int   EXPENTRY ZpArchive(ZCL C, LPZPOPT Opts);