I know WB can do this natively, but interest arose from Kirby's thread about using CLR for Snapshot. I was playing with Icon class but errors. Need help with oStream = ObjectClrNew('System.IO.FileStream',"C:\temp\WB.ico",FileMode.Create)
path = "C:\Program Files (x86)\WinBatch\System\Winbatch.exe"
ObjectClrOption('useany', 'System')
ObjectClrOption('useany', 'System.Drawing')
ObjectClrOption('useany', 'System.IO')
oIcon = ObjectClrNew('System.Drawing.Icon')
oStream = ObjectClrNew('System.IO.FileStream',"C:\temp\WB.ico",FileMode.Create)
cIcon = oIcon.ExtractAssociatedIcon(path)
cIcon.Save(oStream)
oIcon.Dispose()
oIcon = 0
oStream.Dispose()
oStream = 0
Exit
See the previous discussions regarding enumerations being a type and constructors/methods with multiple overloads.
ObjectClrOption('useany', 'System.IO')
enumFileMode = ObjectClrNew('System.IO.FileMode')
FModeCreate = ObjectClrType('System.IO.FileMode', enumFileMode.Create)
oStream = ObjectClrNew('System.IO.FileStream',"C:\temp\WB.ico",FModeCreate )
Thanks, as usual. Did check that output [for another exe] would work as WB compiled Icon - but poor quality. I believe the format is 32x32.
You could eliminate the stream object with
oIcon.ExtractAssociatedIcon(path).ToBitmap().Save("C:\temp\WB.ico")
but that really saves as .png -
Thanks everyone.
This growing library of CLR examples really helps an examples-based learner like me!
-Kirby