Exemple #1
0
        internal static string GetLoadedModuleFileName(string module)
        {
#if !FEATURE_PAL // FEATURE_PAL does not fully support FileVersionInfo
            IntPtr h = UnsafeNativeMethods.GetModuleHandle(module);
            if (h == IntPtr.Zero)
            {
                return(null);
            }

            StringBuilder buf = new StringBuilder(256);
            if (UnsafeNativeMethods.GetModuleFileName(h, buf, 256) == 0)
            {
                return(null);
            }

            String fileName = buf.ToString();
            if (StringUtil.StringStartsWith(fileName, "\\\\?\\")) // on Whistler GetModuleFileName migth return this
            {
                fileName = fileName.Substring(4);
            }
            return(fileName);
#else // !FEATURE_PAL
            // ROTORTODO
            return(String.Empty);
#endif // !FEATURE_PAL
        }
        internal static string GetLoadedModuleFileName(string module)
        {
            IntPtr moduleHandle = System.Web.UnsafeNativeMethods.GetModuleHandle(module);

            if (moduleHandle == IntPtr.Zero)
            {
                return(null);
            }
            StringBuilder filename = new StringBuilder(0x100);

            if (System.Web.UnsafeNativeMethods.GetModuleFileName(moduleHandle, filename, 0x100) == 0)
            {
                return(null);
            }
            string str = filename.ToString();

            if (StringUtil.StringStartsWith(str, @"\\?\"))
            {
                str = str.Substring(4);
            }
            return(str);
        }