While ExtractAssociatedIcon(...) is one way of fetching the icon of the associated application of a file, FWH provides much simpler way.
Most used FW_ReadImage()/oWnd:ReadImage() can also be used.
Just to check, please run this one line code:
XIMAGE( "name.pdf(256x256)" )
FWH also allows us to select the size of the icon, vix. 16x16, 32x32, 64x64 or 256x256. Just add "(64x64") to the file name and use the function.
Next:
For base64 encoding of any image, FWH provides the class TImageBase64() (file fwh\source\classes\imageb64.prg)
Now let us see how to use.
In this sample, we will select 32x32 iconsize and prepare Base64 tag to be included in the html script directly.
We will also test a sample HTML
// Read icon --> bmp --> png formatted string
aBmp := FW_ReadImage( nil, ".pdf(32x32)" )
cPng := GDIP_BMP2PNGSTR( aBmp[ 1 ] )
PalBmpFree( aBmp )
//
// Use the class to prepare base64 tag
oImage64 := TImageBase64():New( cPng )
cTag := oImage64:MakeText( .f., .t., .f. )
oImage64:TestHtml() // if you want to test before using the tag
cTag in the above program looks like this:
"<img src="data:image/png;base64,iVBORw0KGgoAAAANSU...../>"
You can insert this html Tag at the desired place in your HTML code.
To make sure this tag really works, you can test with:
Note:
If we want Icon of 16x16 or 32x32, we need not specify the full pdf file name. It is enough to specify ".pdf(32x32)"
If we want icon size 64x64 or 256x256, then we need to specify an existing file name in full.