Finding MIME Types?
Finding MIME Types?
Anybody know whats the best way to find a MIME type for a given file with regard to email? I know the MIME type for a *.jpg file is 'image/jpeg' but how would any email app find these out? Is there a WinAPI command to access whats locally stored?
Re: Finding MIME Types?
Hmm... I don't understand the 'locally stored' bit of your question.
MIME-Types aren't a matter of APIs or OS-Installations.
They're defined in RFCs. RFC 2046 might be the right one for you.
Just have a search with your favourite searchengine using "mime + types" and I bet you'll find what you're looking for.
And don't trust in things people from Redmond might tell you!
MIME-Types aren't a matter of APIs or OS-Installations.
They're defined in RFCs. RFC 2046 might be the right one for you.
Just have a search with your favourite searchengine using "mime + types" and I bet you'll find what you're looking for.
And don't trust in things people from Redmond might tell you!
Good programmers don't comment their code. It was hard to write, should be hard to read.
I understand about the RFC docs, i've already been through a few 8O
I just wondered if there was something like a locally stored 'extension map file' within windows. something like this: http://archive.ncsa.uiuc.edu/SDG/Softwa ... n-map.html i could parse to match extensions with MIME types. Where does Outlook Express, etc... find these type out from?
I just wondered if there was something like a locally stored 'extension map file' within windows. something like this: http://archive.ncsa.uiuc.edu/SDG/Softwa ... n-map.html i could parse to match extensions with MIME types. Where does Outlook Express, etc... find these type out from?
I (only) guess it's defined. Did you try some extraordinary types?Kale wrote:Where does Outlook Express, etc... find these type out from?
Does Outlook really identify them or is there a "application/octet-stream" in the header?
Good programmers don't comment their code. It was hard to write, should be hard to read.
- tinman
- PureBasic Expert

- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
If you go to the View menu in a Windows Explorer window, then Options, then file types and click on a type, you get a content type. So I think it would be stored somewhere, rather than every application having it's own table of things.
Running redegit then searching for "image/png" gives me a list of mime types stored in the registry.
HKEY_CLASSES_ROOT\MIME\Database\Content Type\image/png
In there it also lists the extension. I'm guessing there is also a reverse method (extension to MIME type).
Running redegit then searching for "image/png" gives me a list of mime types stored in the registry.
HKEY_CLASSES_ROOT\MIME\Database\Content Type\image/png
In there it also lists the extension. I'm guessing there is also a reverse method (extension to MIME type).
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
- tinman
- PureBasic Expert

- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
As traumatic mentioned "application/octet-stream" is a general binary 8-bits-per-symbol MIME type. Which is always better than defaulting to "text/plain" and having your browser trying to save binary files either with an extension (IE) or corrupting the data (NS4.7).Kale wrote:could use a generic one for them. ;)
Gagh!
;)
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
This seems to work 
Code: Select all
Procedure.s GetMIMEType(Extension.s)
Extension = "." + Extension
hKey.l = 0
KeyValue.s = Space(255)
datasize.l = 255
If RegOpenKeyEx_(#HKEY_CLASSES_ROOT, Extension, 0, #KEY_READ, @hKey)
KeyValue = "application/octet-stream"
Else
If RegQueryValueEx_(hKey, "Content Type", 0, 0, @KeyValue, @datasize)
KeyValue = "application/octet-stream"
Else
KeyValue = Left(KeyValue, datasize-1)
EndIf
RegCloseKey_(hKey)
EndIf
ProcedureReturn KeyValue
EndProcedure
key.s=GetMIMEType("gif")
MessageRequester("ReadLocalKey",key,0)
