Analyze file type II (COM)




This method analyzes a file (or buffer) and attempts to guess its type, detects files of which the file extensions may have been altered, and recursively analyzes contents of archive files.

Function prototype

HRESULT AnalyzeFileTypeEx2
[in] VARIANT FileNameOrBuffer,
[out] VARIANT * InArgsArray,
[out, retval] VARIANT * OutArgsArray




Data Type


If FileNameOrBuffer is of type string then it is treated as a file name to be analyzed. Otherwise, if it is a byte array, it is treated as a memory buffer that should be analyzed.

String (file)


Byte array (buffer)


A list of input arguments in the following order:

[0] Detect file extension mismatches. Result can be read from OutArgsArray. Set this to one of the following:

a. True - detect mismatches if the input file’s extension doesn’t match any of our suggested extensions

b. False - do not detect mismatches

[1] If mismatch detection and recursive analysis is enabled, stop analyzing upon a mismatch and return immediately with results up until the file that contained the mismatch. Set this to one of the following:

a. True – stop analyzing on the first mismatch

b. False – analyze all the files within an archive

[2] Analyze the full contents of archive files along with the archive file itself. Set this to one of the following:

a. True – recursively analyze archive files

b. False – only analyze the input file


Variant Array

[0] Boolean

[1] Boolean

[2] Boolean



A list of output arguments in the following order:

[0] If detection of file extension mismatch is enabled, this flag will indicate whether a mismatch was detected. This will be set to one of the following:

a. 0 – no mismatch is detected

b. 1 – a file extension mismatch was found while analyzing the input file or the contents of the archive

c. 2 –unknown because of no detection of file type and / or the input was a buffer

[1] Array containing the analyzed file(s) and file type information – consisting of the file name, file description, a short type, suggested extension, and extension mismatch flag


Variant Array

[0] UINT32 (mismatch flag)

[1] Variant Array (files)


Variant Array (files)

[0][0] String (file name)

[0][1] Variant Array (file info)

[0][2] UINT32 (mismatch flag)


Variant Array (file info)

[0][0] Long type

[0][1] Short type

[0][2] Suggested Extension


Comparison with AnalyzeFileTypeEx()

In addition to returning similar results as AnalyzeFileTypeEx, this method analyzes a file and the contents if it is an archive file. It also gives one or more suggestions for the file type information (description, category, and suggested extension) when available. Additionally, it can raise a flag if the extension of a file does not match any suggested extensions. The caller can specify to abort further analysis on the first mismatch. There are three levels of VARIANT arrays, the last two levels consisting of 2-dimensional SafeArrays.

Upon analysis with AnalyzeFileTypeEx(), if specific details of the file type could be not retrieved, the ‘FileTypeShort’ result will be set to the letter ‘O’, throwing it into the “others” category. In contrast, AnalyzeFileTypeEx2() will return an empty array, indicating that details could not be retrieved for the file