11
Nov
by Chris
If you are using a GUI it is nice to have a form icon. I didn't want to have an ico or bmp file in the same folder as the ps1 file because it might get lost. So this bit of code can be put into your ps1 source file to give you a form icon
$iconstring = (@"
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACB
VGfHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUw
AADqYAAAOpgAABdwnLpRPAAAADBQTFRFAAAAgAAA
AIAAgIAAAACAgACAAICAwMDAgICA/wAAAP8A//8A
AAD//wD/AP//////TxMmSQAAACxJREFUKM9jcEED
DLQSYGBgQBFw4N69gQECIALcu+GAZQQKODDAAS2j
gUQBAF/KwfacIWwzAAAAAElFTkSuQmCC
"@).replace("`n", "")
$memory = new-object System.IO.MemoryStream
$memory.write(($bytes=[System.Convert]::FromBase64String($iconstring)), 0, $bytes.length)
$FORM.Icon = [System.Drawing.Icon]::FromHandle((new-object System.Drawing.Bitmap -argument $memory).GetHIcon())
Before and After
