|
UINT GetFileContentType( |
|
LPCTSTR lpszFileName, |
|
|
LPTSTR lpszContentType, |
|
|
INT cchContentType |
|
); |
UINT GetFileContentType( |
|
LPCTSTR lpszFileName, |
|
|
CString& strContentType |
|
); |
The GetFileContentType method returns the content type for
the specified file.
Parameters
- lpszFileName
- Pointer to a string which specifies the name of
the file for which content type information is returned.
- lpszContentType
- Pointer to a string buffer that will contain the MIME type for
the specified file. This may be a NULL pointer, in which case this
parameter is ignored. If a buffer is provided, it is recommended
that it be at least 64 characters in length.
- cchContentType
- An integer which specifies the maximum number of characters,
including the terminating null character, which may be copied into the
string buffer.
Return Value
If the method succeeds, the return value is the content type of
the specified file. If the method fails, the return value is
MIME_CONTENT_UNKNOWN. To get extended error information, call
GetLastError.
The following values may be returned by this method:
Constant |
Description |
MIME_CONTENT_UNKNOWN |
The file content type is unknown. This value may be returned
if the message handle is invalid, or if the file extension is
unknown and the file could not be opened for read access. |
MIME_CONTENT_APPLICATION |
The file content is application specific. Examples of this
type of file would be a Microsoft Word document or an executable
program. This is also the default type for files which have an
unrecognized file name extension and contain binary data. |
MIME_CONTENT_AUDIO |
The file is an audio file in one of several standard formats.
Examples of this type of file would be a Windows (.wav) file or
MPEG3 (.mp3) file. |
MIME_CONTENT_IMAGE |
The file is an image file in one of several standard formats.
Examples of this type of file would be a GIF or JPEG image
file. |
MIME_CONTENT_TEXT |
The file is a text file. This is also the default type for
files which have an unrecognized file name extension and contain
only printable text data. |
MIME_CONTENT_VIDEO |
The file is a video file in one of several standard formats.
Examples of this type of file would be a Windows (.avi) or
Quicktime (.mov) video file. |
Remarks
The content type for a given file is determined based on the file
name extension, or if the extension is not recognized, the actual
contents of the file. On 32-bit platforms, the system registry is
used to determine the default content type values for a given
extension. In all cases, file types that are explicitly set using the
SetFileContentType method will override the default system
values.
The content type string which is copied to the string buffer is
the standard MIME content type description, which specifies a primary
type and a subtype, separated by a slash. For example, a plain text
file would have a content type of text/plain, while an HTML document
would have a content type of text/html. Binary files may be
associated with a specific application. For example, the content type
for a Microsoft Word document is application/msword. Those binary
files which are not associated with a specific application, or have
an unrecognized file name extension, have a content type of
application/octet-stream.
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csmsgv10.lib
Unicode: Implemented as Unicode and ANSI versions.
See Also
AttachData,
AttachFile,
SetFileContentType
|
|