This is an old revision of the document!
by Jon Ripley, May 2007
To read the MIME type of a file call “FN_GetMIMEType” passing it a file extension, for example:
PRINT "The MIME type of a .html file is ";FN_GetMIMEType("html")
The code for “FN_GetMIMEType” is:
DEF FN_GetMIMEType(T$) LOCAL B%, H%, L%, R%, T% L% = 255 : DIM B% LOCAL L% SYS "RegOpenKeyEx", &80000000, "."+T$, 0, &20001, ^H% TO R% IF R% = 0 THEN SYS "RegQueryValueEx", H%, "Content Type", 0, ^T%, B%, ^L% TO R% REM Uncomment the next line to set a default MIME type if none is found REM IF R% $$B% = MIMEDefault$ SYS "RegCloseKey", H% ENDIF = $$B%
“FN_GetMIMEType” returns an empty string if no MIME type is found in the registry for the requested file extension. To set a default MIME type for all unknown extensions uncomment the specified line and replace MIMEDefault$ with your fail safe type.