Click here to Skip to main content
15,891,423 members
Articles / Programming Languages / C#

Network Stuff (easy socket v3)

Rate me:
Please Sign up or sign in to vote.
4.87/5 (52 votes)
2 Jun 2005 216.6K   6.1K   137  
A class with event handlers for TCP, UDP or ICMP sockets; includes ping, traceroute, whois, ARP, and IPHelper functions and raw packets forging/ capturing.
using System;
using System.Runtime.InteropServices;

    /// <summary>
    /// Description r�sum�e de System.Drawing.Icon.
    /// </summary>
    public class CIcon
    {
        private const UInt32 SHGFI_ICON = 0x100;
        private const UInt32 SHGFI_LARGEICON = 0x0; // 'Large icon
        private const UInt32 SHGFI_SMALLICON = 0x1; // 'Small icon

        [DllImport("shell32.dll")]
        private static extern IntPtr SHGetFileInfo(string pszPath, UInt32 dwFileAttributes, ref SHFILEINFO psfi, UInt32 cbSizeFileInfo, UInt32 uFlags);

        [StructLayout(LayoutKind.Sequential)]
        private struct SHFILEINFO 
        {
            public IntPtr hIcon;
            public IntPtr iIcon;
            public UInt32 dwAttributes;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
            public string szDisplayName;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
            public string szTypeName;
        };

        public static System.Drawing.Icon GetIcon(string filename,bool b_large_icon)
        {
            UInt32 icon_size;
            if (b_large_icon)
                icon_size=SHGFI_LARGEICON;
            else
                icon_size=SHGFI_SMALLICON;

            IntPtr hImgSmall; 
            SHFILEINFO shinfo = new SHFILEINFO();

            hImgSmall = SHGetFileInfo(filename, 0, ref shinfo,(UInt32)Marshal.SizeOf(shinfo),SHGFI_ICON |icon_size);
            System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
                        
            return myIcon;
        }

    }

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
France France

Comments and Discussions