Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than shell32, prefix the name with the module name and a period.
Shell_NotifyIcon (shell32)
.
Retrieves the Notifyicon bounding rectangle.
C# Signature:
[DllImport("shell32.dll", SetLastError = true)]
static extern int Shell_NotifyIconGetRect([In]ref NOTIFYICONIDENTIFIER identifier, [Out]out RECT iconLocation);
[StructLayout(LayoutKind.Sequential)]
public struct RECT
public struct NotifyIconData
{
public Int32 left;
public Int32 top;
public Int32 right;
public Int32 bottom;
public System.Int32 cbSize; // DWORD
public System.IntPtr hWnd; // HWND
public System.Int32 uID; // UINT
public NotifyFlags uFlags; // UINT
public System.Int32 uCallbackMessage; // UINT
public System.IntPtr hIcon; // HICON
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
public System.String szTip; // char[128]
public System.Int32 dwState; // DWORD
public System.Int32 dwStateMask; // DWORD
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=256)]
public System.String szInfo; // char[256]
public System.Int32 uTimeoutOrVersion; // UINT
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=64)]
public System.String szInfoTitle; // char[64]
public System.Int32 dwInfoFlags; // DWORD
//GUID guidItem; > IE 6
}
[StructLayout(LayoutKind.Sequential)]
public struct NOTIFYICONIDENTIFIER
{
public uint cbSize;
public IntPtr hWnd;
public uint uID;
public Guid guidItem;
}
[DllImport("shell32.dll", SetLastError = true)]
private static extern int Shell_NotifyIconGetRect([In]ref NOTIFYICONIDENTIFIER identifier, [Out]out RECT iconLocation);
public static RECT GetNotifyIconRect(IntPtr windowHandle, uint taskbarIconId)
{
var rect = new RECT();
var notifyIcon = new NOTIFYICONIDENTIFIER();
notifyIcon.cbSize = (uint)Marshal.SizeOf(notifyIcon.GetType());
notifyIcon.hWnd = windowHandle;
notifyIcon.uID = taskbarIconId;
var hresult = Shell_NotifyIconGetRect(ref notifyIcon, out rect);
if (hresult == 0x80004005)
{
// E_FAIL, will happen if the icon is not there.
throw new Win32Exception(hresult, "Failed to get icon position.");
}
if (hresult != 0)
{
throw new Win32Exception(hresult);
}
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).