Exemplo n.º 1
0
 public static extern int SizeofResource(SafeModuleHandle hModule, IntPtr hResInfo);
Exemplo n.º 2
0
 public static extern IntPtr FindResource(SafeModuleHandle hModule, IntPtr lpName, ResourceTypes lpType);
Exemplo n.º 3
0
 public static extern IntPtr LoadResource(SafeModuleHandle hModule, IntPtr hResInfo);
Exemplo n.º 4
0
 public IconExtractor(SafeModuleHandle moduleHandle, IList<ResourceName> iconNames)
 {
     _moduleHandle = moduleHandle;
     _iconNames = new ReadOnlyCollection<ResourceName>(iconNames);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Extracts the raw data of the resource from the module.
        /// </summary>
        /// <param name="hModule">The module handle.</param>
        /// <param name="resourceId">The identifier of the resource.</param>
        /// <param name="resourceType">The type of the resource.</param>
        /// <returns>The resource raw data.</returns>
        private static byte[] GetResourceData(SafeModuleHandle hModule, int resourceId, ResourceTypes resourceType)
        {
            //Find the resource in the module.
            IntPtr hResInfo = DllImports.FindResource(hModule, (IntPtr) resourceId, resourceType); 
            if (hResInfo == IntPtr.Zero)
            {
                throw new Win32Exception();
            }
            //Load the resource.
            IntPtr hResData = DllImports.LoadResource(hModule, hResInfo);
            if (hResData == IntPtr.Zero)
            {
                throw new Win32Exception();
            }
            //Lock the resource to read data.
            IntPtr hGlobal = DllImports.LockResource(hResData);
            if (hGlobal == IntPtr.Zero)
            {
                throw new Win32Exception();
            }
            //Get the resource size.
            int resSize = DllImports.SizeofResource(hModule, hResInfo);
            if (resSize == 0)
            {
                throw new Win32Exception();
            }
            //Allocate the requested size.
            byte[] buf = new byte[resSize];
            //Copy the resource data into our buffer.
            Marshal.Copy(hGlobal, buf, 0, buf.Length);

            return buf;
        }
Exemplo n.º 6
0
 public static extern int SizeofResource(SafeModuleHandle hModule, IntPtr hResInfo);
Exemplo n.º 7
0
 public static extern IntPtr LoadResource(SafeModuleHandle hModule, IntPtr hResInfo);
Exemplo n.º 8
0
 public static extern IntPtr FindResource(SafeModuleHandle hModule, IntPtr lpName, ResourceTypes lpType);