Exemplo n.º 1
0
        /// <summary>
        /// Enumerate resource languages within a resource by name
        /// </summary>
        private bool EnumResourceLanguages(IntPtr hModule, IntPtr lpszType, IntPtr lpszName, ushort wIDLanguage, IntPtr lParam)
        {
            string type = ResourceUtil.GetResourceName(lpszType);

            List <Resource> resources = null;

            if (!_resources.TryGetValue(type, out resources))
            {
                resources        = new List <Resource>();
                _resources[type] = resources;
            }

            IntPtr hResource       = Kernel32.FindResourceEx(hModule, lpszType, lpszName, wIDLanguage);
            IntPtr hResourceGlobal = Kernel32.LoadResource(hModule, hResource);
            int    size            = Kernel32.SizeofResource(hModule, hResource);

            Resource rc = null;

            switch (ResourceUtil.GetResourceName(lpszType))
            {
            case "16":     // Kernel32.RT_VERSION:
                rc = new VersionResource(hModule, hResourceGlobal, lpszType, lpszName, wIDLanguage, size);
                break;

            case "14":     // Kernel32.RT_GROUP_ICON
                rc = new GroupIconResource(hModule, hResourceGlobal, lpszType, lpszName, wIDLanguage, size);
                break;

            // \todo: specialize other resource types
            default:
                rc = new Resource(hModule, hResourceGlobal, lpszType, lpszName, wIDLanguage, size);
                break;
            }

            resources.Add(rc);
            return(true);
        }