Example #1
0
 internal static extern bool FdiCopy(
     IntPtr hfdi,
     string cabinetName,
     string cabinetPath,
     int flags,
     FdiNotifyDelegate fnNotify,
     IntPtr fnDecrypt,
     IntPtr userData);
Example #2
0
 private static bool FdiCopy(
     IntPtr hfdi,
     FdiNotifyDelegate fnNotify)
 {
     return(FdiCopy(hfdi,
                    "<notused>",
                    "<notused>",
                    0,
                    fnNotify,
                    IntPtr.Zero,
                    IntPtr.Zero));
 }
Example #3
0
        /// <summary>
        /// Extract files from a cabinet.
        /// </summary>
        /// <param name="hfdi">Handle to FDI context created by FdiCreate.</param>
        /// <param name="cabinetName">Name and extension of cabinet file.</param>
        /// <param name="cabinetPath">Path that contains cabinet files.</param>
        /// <param name="fnNotify">Notification delegate.  Must not be null.</param>
        /// <param name="fnDecrypt">Decryption delegate.  Pass null if not used.</param>
        /// <param name="userData">User specified data to pass to notification and decryption
        /// functions.  May be null if not used.</param>
        /// <returns>Returns True if successful.
        /// Returns False if an error occurs.  The CabError structure that was passed to the
        /// FdiCreate call will contain error information.</returns>
        internal static bool FdiCopy(
            IntPtr hfdi,
            string cabinetName,
            string cabinetPath,
            FdiNotifyDelegate fnNotify,
            FdiDecryptDelegate fnDecrypt,
            object userData)
        {
            // create a GCHandle for the user data
            GCHandle gch = GCHandle.Alloc(userData);
            try
            {
                // Ensure that the cabinet path has a trailing directory separator.
                string cabPath;
                if (cabinetPath == string.Empty || cabinetPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    cabPath = cabinetPath;
                else
                    cabPath = cabinetPath + Path.DirectorySeparatorChar;

                // call FdiCopy
                bool rslt = FdiCopy(hfdi, cabinetName, cabPath, 0, fnNotify, fnDecrypt, (IntPtr)gch);
                // Prevent the garbage collector from cleaning up the cabPath
                // string until FdiCopy returns.
                GC.KeepAlive(cabPath);
                return rslt;
            }
            finally
            {
                gch.Free();
            }
        }
Example #4
0
 private static extern bool FdiCopy(
     IntPtr hfdi,
     string cabinetName,
     string cabinetPath,
     int flags,
     FdiNotifyDelegate fnNotify,
     FdiDecryptDelegate fnDecrypt,
     IntPtr userData);
Example #5
0
 private static extern Int32 FdiCopy(
     IntPtr hfdi,
     String cabinetName,
     String cabinetPath,
     Int32 flags,
     FdiNotifyDelegate fnNotify,
     IntPtr fnDecrypt,
     IntPtr userData);