Example #1
0
            public static string TryLoadStringResource([NotNull] string sDllFilename, uint nResourceId)
            {
                if (sDllFilename == null)
                {
                    throw new ArgumentNullException("sDllFilename");
                }

                // DLL
                void *hModule = Kernel32Dll.LoadLibraryW(Path.GetFullPath(Environment.ExpandEnvironmentVariables(sDllFilename)));

                if (hModule == null)
                {
                    return(null);
                }

                // Resource
                UInt16 *buffer = stackalloc UInt16[StringLen];

                if (LoadStringW(hModule, nResourceId, buffer, StringLen) == 0)
                {
                    return(null);
                }

                buffer[StringLen - 1] = 0;                 // Ensure it's Null-terminated
                return(new string((char *)buffer));
            }
Example #2
0
 /// <summary>
 /// Checks whether the UxTheme DLL is available on this platform.
 /// </summary>
 public static bool IsAvailable()
 {
     return(Kernel32Dll.LoadLibraryW("UxTheme.dll") != null);
 }