This function returns a file's Mime type. NB: it is not a function completely validating the content of file.
In Windows, apart from certain Mime types supported as standard, the type is derived from the file extension and the information contained in the registry. It is therefore possible for you to have an "application/octet-stream" return if the registry is not entered (if no installed application handles this file type => see if the "Content Type" value appears in the "HKEY_CLASSES_ROOT\<FILE_EXTENSION>" key).
Context
Windows client
Windows server
- Java client
Java server
Adelia Web Client
Adelia Cloud client
Event Adelia client
Parameters
ALPHA(n) |
FileName |
Name of the file to be read. |
ALPHA(n) | MimeType |
Variable which must contain the Mime type of the tested file. |
NUM_BIN_4 | MimeTypeLg | Length of the MimeType variable. If the Mime type length is over MimeTypeLg, the function fails and returns a -2 error code and the required length in MimeTypeLg. |
NUM_BIN_2 |
ReturnCode |
Return code for the operation: 0 Operation completed successfully. -1 An unexpected error occurred. -2 Cannot read file. -3 The MimeType variable length is too short. |
Example
ALPHA(250) FileName
ALPHA(250) MimeType
NUM_BIN_4 MimeTypeLg
NUM_BIN_2 ReturnCode
...
FileName = 'c:\temp\document.docx'
MimeTypeLg = 250
CALL_DLL 'VATOOLBX.DLL' 'VaToolBxGuessMimeTypeFile' FileName MimeType MimeTypeLg ReturnCode
* => The value of MimeType is "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
List of VaToolBx DLL functions by topic