var icon = new Icon(GetResourceStream("Cards.ico"));
GetResourceStream is a custom method of mine to load the icon file from the embedded resources.
To create the window, you already defined a window class struct somewhere.var windowClass = new WindowClassEx();All you have to do, is pass the icon's internal handle to this structure.
windowClass.Icon = icon.Handle;And make sure the icon object is not destroyed while the window is open.
Windows will look for a small icon for the title bar in Icon when IconSmall is not set.