Shell struct v5.0 and later中的NOTIFYICONDATA结构定义为:
typedef struct _NOTIFYICONDATA {
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
TCHAR szTip[64];
DWORD dwState;
DWORD dwStateMask;
TCHAR szInfo[256];
union {
UINT uTimeout;
UINT uVersion;
};
TCHAR szInfoTitle[64];
DWORD dwInfoFlags;
GUID guidItem;
} NOTIFYICONDATA, *PNOTIFYICONDATA;
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
TCHAR szTip[64];
DWORD dwState;
DWORD dwStateMask;
TCHAR szInfo[256];
union {
UINT uTimeout;
UINT uVersion;
};
TCHAR szInfoTitle[64];
DWORD dwInfoFlags;
GUID guidItem;
} NOTIFYICONDATA, *PNOTIFYICONDATA;
而微软Framework 1.0/1.1中实现的NOTIFYICONDATA是:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto, Pack=1)]
public class NOTIFYICONDATA
{
public int cbSize;
public IntPtr hWnd;
public int uID;
public int uFlags;
public int uCallbackMessage;
public IntPtr hIcon;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=0x40)]
public string szTip;
public NOTIFYICONDATA()
{
this.cbSize = Marshal.SizeOf(typeof(NativeMethods.NOTIFYICONDATA));
}
}
public class NOTIFYICONDATA
{
public int cbSize;
public IntPtr hWnd;
public int uID;
public int uFlags;
public int uCallbackMessage;
public IntPtr hIcon;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=0x40)]
public string szTip;
public NOTIFYICONDATA()
{
this.cbSize = Marshal.SizeOf(typeof(NativeMethods.NOTIFYICONDATA));
}
}
不过稍微感到欣慰的是在Framework 2.0中,NotifyIcon支持了v5.0以后的Balloon Tip功能。