Wrappers for Native Methods and Structs. This type is intended for internal use only
示例#1
0
        /// <summary>
        /// Get a string resource given a resource Id
        /// </summary>
        /// <param name="resourceId">The resource Id</param>
        /// <returns>The string resource corresponding to the given resource Id. Returns null if the resource id
        /// is invalid or the string cannot be retrieved for any other reason.</returns>
        public static string GetStringResource(string resourceId)
        {
            string[] parts;
            string   library;
            int      index;

            if (string.IsNullOrEmpty(resourceId))
            {
                return(string.Empty);
            }

            // Known folder "Recent" has a malformed resource id
            // for its tooltip. This causes the resource id to
            // parse into 3 parts instead of 2 parts if we don't fix.
            resourceId = resourceId.Replace("shell32,dll", "shell32.dll");
            parts      = resourceId.Split(new char[] { ',' });

            library = parts[0];
            library = library.Replace(@"@", string.Empty);
            library = Environment.ExpandEnvironmentVariables(library);
            IntPtr handle = CoreNativeMethods.LoadLibrary(library);

            parts[1] = parts[1].Replace("-", string.Empty);
            index    = int.Parse(parts[1], CultureInfo.InvariantCulture);

            StringBuilder stringValue = new StringBuilder(255);
            int           retval      = CoreNativeMethods.LoadString(handle, index, stringValue, 255);

            return(retval != 0 ? stringValue.ToString() : null);
        }
 /// <summary>
 /// Release the handle
 /// </summary>
 /// <returns>true if handled is release successfully, false otherwise</returns>
 protected override bool ReleaseHandle()
 {
     if (CoreNativeMethods.DeleteObject(this.handle))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#3
0
        /// <summary>
        /// Release the handle
        /// </summary>
        /// <returns>true if handled is release successfully, false otherwise</returns>
        protected override bool ReleaseHandle()
        {
            if (this.IsInvalid)
            {
                return(true);
            }

            if (CoreNativeMethods.DestroyWindow(this.handle) != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 internal static extern bool GetWindowRect( IntPtr hwnd, ref CoreNativeMethods.RECT rect );
 internal static extern int DwmSetIconicLivePreviewBitmap(
     IntPtr hwnd,
     IntPtr hbitmap,
     ref CoreNativeMethods.POINT ptClient,
     uint flags);
 internal static extern bool ClientToScreen(
     IntPtr hwnd,
     ref CoreNativeMethods.POINT point);
 public virtual extern void SetRect( [In, Out] ref IntPtr phdwp, CoreNativeMethods.RECT rcBrowser );