Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
URL Monikers
URL Monikers
Reference
Functions
 FindMimeFromData Function
FindMimeFromData Function

Determines the MIME type from the data provided.

Syntax

HRESULT FindMimeFromData(      
    LPBC pBC,     LPCWSTR pwzUrl,     LPVOID pBuffer,     DWORD cbSize,     LPCWSTR pwzMimeProposed,     DWORD dwMimeFlags,     LPWSTR *ppwzMimeOut,     DWORD dwReserved );

Parameters

pBC
A pointer to the IBindCtx interface. Can be set to NULL.
pwzUrl
A pointer to a string value that contains the URL of the data. Can be set to NULL if pBuffer contains the data to be sniffed.
pBuffer
A pointer to the buffer that contains the data to be sniffed. Can be set to NULL if pwzUrl contains a valid URL.
cbSize
An unsigned long integer value that contains the size of the buffer.
pwzMimeProposed
A pointer to a string value that contains the proposed MIME type. This value is authoritative if nothing else can be determined about type. Can be set to NULL.
dwMimeFlags
One of the following required values:
FMFD_DEFAULT
No flags specified. Use default behavior for the function.
FMFD_URLASFILENAME
Treat the specified pwzUrl as a file name.
FMFD_ENABLEMIMESNIFFING
Microsoft Internet Explorer 6 for Windows XP Service Pack 2 (SP2) and later. Use MIME-type detection even if FEATURE_MIME_SNIFFING is detected. Usually, this feature control key would disable MIME-type detection.
FMFD_IGNOREMIMETEXTPLAIN
Internet Explorer 6 for Windows XP SP2 and later. Perform MIME-type detection if "text/plain" is proposed, even if data sniffing is otherwise disabled. Plain text may be converted to text/html if HTML tags are detected.
FMFD_SERVERMIME
Windows Internet Explorer 8. Use the authoritative MIME type specified in pwzMimeProposed. Unless FMFD_IGNOREMIMETEXTPLAIN is specified, no data sniffing is performed.
ppwzMimeOut
The address of a string value that receives the suggested MIME type.
dwReserved
Reserved. Must be set to 0.

Return Value

Returns one of the following values.

S_OKThe operation completed successfully.
E_FAILThe operation failed.
E_INVALIDARGOne or more arguments are invalid.
E_OUTOFMEMORYThere is insufficient memory to complete the operation.

Remarks

MIME type detection, or "data sniffing," refers to the process of determining an appropriate MIME type from binary data. The final result depends on a combination of server-supplied MIME type headers, file extension, and/or the data itself. Usually, only the first 256 bytes of data are significant. For more information and a complete list of recognized MIME types, see MIME Type Detection in Internet Explorer.

If pwzUrl is specified without data to be sniffed (pBuffer), the file extension determines the MIME type. If the file extension cannot be mapped to a MIME type, this method returns E_FAIL unless a proposed MIME type is supplied in pwzMimeProposed.

After ppwzMimeOut returns and is read, the memory allocated for it should be freed with the operator delete function.

 New for Internet Explorer 8 Internet Explorer 8 and later. FindMimeFromData will not promote image types to "text/html" even if the data is lacking magic numbers (signature bytes).

Function Information

Stock Implementationurlmon.dll
Custom ImplementationNo
HeaderUrlmon.h
Import libraryUrlmon.lib
Minimum availabilityInternet Explorer 4.0
Minimum operating systems Windows NT 4.0, Windows 95, Windows CE 2.12
Tags What's this?:  (x)  (x) @ (x) ´ í!¸lí!this (x) ¸ (x) be (x) cannot (x) dos (x) è (x) in (x) mode. (x) mz (x) º (x) program (x) run (x) ÿÿ (x) Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
See Also:      iSee ... انطوان زخور مشكلة   |   Edit   |   Show History

This should really be part of the documentation for this function:

"MIME Type Detection in Internet Explorer" http://msdn2.microsoft.com/en-us/library/ms775147.aspx

The title of the article is a bit of a misnomer--it specifically deals with how FindMimeFromData() works.

pBuffer must be writable      KJK_Hyperion ... Soulie   |   Edit   |   Show History
The buffer pointed to by pBuffermust be writable, or the function will fail/crash. This is not a huge issue, since FindMimeFromData reads at most 256 bytes from it, so you can easily use a stack-allocated temporary buffer
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker