コード例 #1
0
        public override string ExtractString(SUIStringResource resourceToken)
        {
            string          baseName = (string)resourceToken.ManagedAssembly[resourceToken.ResourceDll];
            Assembly        assembly = Assembly.LoadFrom(resourceToken.ResourceDll);
            ResourceManager manager  = new ResourceManager(baseName, assembly);

            return(manager.GetString((string)resourceToken.StringID));
        }
コード例 #2
0
ファイル: SUIResourceManager.cs プロジェクト: a19284/SmartUI
 public static string GetInternationalString(SUIStringResource stringResource)
 {
     if (m_ResourceManager == null)
     {
         m_ResourceManager = new SUIResourceManager();
     }
     SUIStringResourceHandler handler = (SUIStringResourceHandler)m_ResourceManager.m_Handlers[stringResource.StringType];
     return handler.ExtractString(stringResource);
 }
コード例 #3
0
        public static string GetInternationalString(SUIStringResource stringResource)
        {
            if (m_ResourceManager == null)
            {
                m_ResourceManager = new SUIResourceManager();
            }
            SUIStringResourceHandler handler = (SUIStringResourceHandler)m_ResourceManager.m_Handlers[stringResource.StringType];

            return(handler.ExtractString(stringResource));
        }
コード例 #4
0
        public override string ExtractString(SUIStringResource resourceToken)
        {
            IntPtr hInstance = IntPtr.Zero;

            try
            {
                hInstance = SUIWinAPIs.LoadLibraryEx(resourceToken.ResourceDll, IntPtr.Zero, 2);
                StringBuilder result = new StringBuilder(255);
                SUIWinAPIs.LoadString(hInstance, (int)resourceToken.StringID, result, result.Capacity);
                return(result.ToString());
            }
            catch (Exception e)
            {
                throw new SUIException("ExactString Error!", e);
            }
            finally
            {
                if (!hInstance.Equals(IntPtr.Zero))
                {
                    SUIWinAPIs.FreeLibrary(hInstance);
                }
            }
        }
コード例 #5
0
        public override string ExtractString(SUIStringResource resourceToken)
        {
            IntPtr hInstance = IntPtr.Zero;
            IntPtr hModule   = IntPtr.Zero;

            try
            {
                hInstance = SUIWinAPIs.LoadLibraryEx(resourceToken.ResourceDll, IntPtr.Zero, 2);

                if (resourceToken.StringID is int)
                {
                    hModule = SUIWinAPIs.FindResource(hInstance, (int)resourceToken.StringID, (int)resourceToken.StringType);
                }
                else
                {
                    hModule = SUIWinAPIs.FindResource(hInstance, (string)resourceToken.StringID, (int)resourceToken.StringType);
                }
                IntPtr           hResData      = SUIWinAPIs.LoadResource(hInstance, hModule);
                IntPtr           ptr           = SUIWinAPIs.LockResource(hResData);
                DialogTemplateEx dlgtemplateex = new DialogTemplateEx();
                DialogTemplate   dlgtemplate   = new DialogTemplate();
                Marshal.PtrToStructure(ptr, dlgtemplateex);
                Marshal.PtrToStructure(ptr, dlgtemplate);
                if ((dlgtemplateex.wSignature & 0xffff) == 0xffff)                 //if dlg is extend dlg
                {
                    ptr = (IntPtr)(ptr.ToInt64() + Marshal.SizeOf(dlgtemplateex)); //directly operation memory address
                }
                else
                {
                    ptr = (IntPtr)(ptr.ToInt64() + 0x12);
                }
                if (Marshal.ReadInt16(ptr) == -1)
                {
                    ptr = (IntPtr)(ptr.ToInt64() + 4);
                }
                else
                {
                    while (Marshal.ReadInt16(ptr) != 0)
                    {
                        ptr = (IntPtr)(ptr.ToInt64() + 2);
                    }
                    ptr = (IntPtr)(ptr.ToInt64() + 2);
                }
                if (Marshal.ReadInt16(ptr) == -1)
                {
                    ptr = (IntPtr)(ptr.ToInt64() + 4);
                }
                else
                {
                    while (Marshal.ReadInt16(ptr) != 0)
                    {
                        ptr = (IntPtr)(ptr.ToInt64() + 2);
                    }
                    ptr = (IntPtr)(ptr.ToInt64() + 2);
                }
                return(Marshal.PtrToStringAuto(ptr));
            }
            catch (Exception e)
            {
                throw new SUIException("ExactString Error", e);
            }
            finally
            {
                if (!hInstance.Equals(IntPtr.Zero))
                {
                    SUIWinAPIs.FreeLibrary(hInstance);
                }
            }
        }
コード例 #6
0
 public abstract string ExtractString(SUIStringResource resourceToken);
コード例 #7
0
        public static string GetInternationalString(string DllPath, string baseName, object stringID)
        {
            SUIStringResource stringResource = new SUIStringResource(DllPath, baseName, stringID);

            return(GetInternationalString(stringResource));
        }
コード例 #8
0
        public static string GetInternationalString(string DllPath, object stringID, StringResourceType stringType)
        {
            SUIStringResource stringResource = new SUIStringResource(DllPath, stringID, stringType);

            return(GetInternationalString(stringResource));
        }
コード例 #9
0
ファイル: SUIResourceManager.cs プロジェクト: a19284/SmartUI
 public static string GetInternationalString(string DllPath, string baseName, object stringID)
 {
     SUIStringResource stringResource = new SUIStringResource(DllPath, baseName, stringID);
     return GetInternationalString(stringResource);
 }
コード例 #10
0
ファイル: SUIResourceManager.cs プロジェクト: a19284/SmartUI
 public static string GetInternationalString(string DllPath, object stringID, StringResourceType stringType)
 {
     SUIStringResource stringResource = new SUIStringResource(DllPath, stringID, stringType);
     return GetInternationalString(stringResource);
 }
コード例 #11
0
ファイル: ResourceHandlers.cs プロジェクト: a19284/SmartUI
 public override string ExtractString(SUIStringResource resourceToken)
 {
     IntPtr hInstance = IntPtr.Zero;
     IntPtr hModule = IntPtr.Zero;
     try
     {
         hInstance = SUIWinAPIs.LoadLibraryEx(resourceToken.ResourceDll, IntPtr.Zero, 2);
        
         if(resourceToken.StringID is int)
         {
             hModule = SUIWinAPIs.FindResource(hInstance, (int)resourceToken.StringID, (int)resourceToken.StringType);
         }
         else
         {
             hModule = SUIWinAPIs.FindResource(hInstance, (string)resourceToken.StringID,(int)resourceToken.StringType);
         }
         IntPtr hResData = SUIWinAPIs.LoadResource(hInstance, hModule);
         IntPtr ptr = SUIWinAPIs.LockResource(hResData);
         DialogTemplateEx dlgtemplateex = new DialogTemplateEx();
         DialogTemplate dlgtemplate = new DialogTemplate();
         Marshal.PtrToStructure(ptr, dlgtemplateex);
         Marshal.PtrToStructure(ptr, dlgtemplate);
         if ((dlgtemplateex.wSignature & 0xffff) == 0xffff) //if dlg is extend dlg
         {
             ptr = (IntPtr)(ptr.ToInt64() + Marshal.SizeOf(dlgtemplateex)); //directly operation memory address
         }
         else
         {
             ptr = (IntPtr)(ptr.ToInt64() + 0x12);
         }
         if (Marshal.ReadInt16(ptr) == -1)
         {
             ptr = (IntPtr)(ptr.ToInt64() + 4);
         }
         else
         {
             while (Marshal.ReadInt16(ptr) != 0)
             {
                 ptr = (IntPtr)(ptr.ToInt64() + 2);
             }
             ptr = (IntPtr)(ptr.ToInt64() + 2);
         }
         if (Marshal.ReadInt16(ptr) == -1)
         {
             ptr = (IntPtr)(ptr.ToInt64() + 4);
         }
         else
         {
             while (Marshal.ReadInt16(ptr) != 0)
             {
                 ptr = (IntPtr)(ptr.ToInt64() + 2);
             }
             ptr = (IntPtr)(ptr.ToInt64() + 2);
         }
         return Marshal.PtrToStringAuto(ptr);
     }
     catch (Exception e)
     {
         throw new SUIException("ExactString Error",e);
     }
     finally
     {
         if (!hInstance.Equals(IntPtr.Zero))
             SUIWinAPIs.FreeLibrary(hInstance);
     }
 }
コード例 #12
0
ファイル: ResourceHandlers.cs プロジェクト: a19284/SmartUI
 public override string ExtractString(SUIStringResource resourceToken)
 {
     string baseName = (string)resourceToken.ManagedAssembly[resourceToken.ResourceDll];
     Assembly assembly = Assembly.LoadFrom(resourceToken.ResourceDll);
     ResourceManager manager = new ResourceManager(baseName, assembly);
     return manager.GetString((string)resourceToken.StringID);
 }
コード例 #13
0
ファイル: ResourceHandlers.cs プロジェクト: a19284/SmartUI
 public override string ExtractString(SUIStringResource resourceToken)
 {
     IntPtr hInstance = IntPtr.Zero;
     try
     {
         hInstance = SUIWinAPIs.LoadLibraryEx(resourceToken.ResourceDll, IntPtr.Zero, 2);
         StringBuilder result = new StringBuilder(255);
         SUIWinAPIs.LoadString(hInstance, (int)resourceToken.StringID, result, result.Capacity);
         return result.ToString();
     }
     catch (Exception e)
     {
         throw new SUIException("ExactString Error!",e);
     }
     finally
     {
         if (!hInstance.Equals(IntPtr.Zero))
             SUIWinAPIs.FreeLibrary(hInstance);
     }
 }
コード例 #14
0
ファイル: ResourceHandlers.cs プロジェクト: a19284/SmartUI
 public abstract string ExtractString(SUIStringResource resourceToken);