Source code 
Author Message
 Source code

Given all the negative stuff posted here lately, I just gotta post some code
to bring my spirits up:

#COMPILE EXE
#INCLUDE "WIN32API.INC"

'---------------------------------------------------------------------------
' Return the MIME type info from the registry for a given file extension
'
FUNCTION GetMimeType(BYVAL fileExt AS STRING) AS STRING

  LOCAL hKey    AS LONG
  LOCAL Result  AS LONG
  LOCAL KeyType AS LONG
  LOCAL buffer  AS ASCIIZ * 64
  LOCAL s       AS LONG

' ** We need a valid file extension
  IF ISFALSE INSTR(fileExt, ".") THEN
    fileExt = "." & fileExt
  ELSE
    fileExt = MID$(fileExt, INSTR(-1, fileExt, "."))
  END IF

' ** Open the section
  IF RegOpenKeyEx(%HKCR, BYCOPY fileExt, 0, %KEY_ALL_ACCESS, _
                  hKey) <> %ERROR_SUCCESS THEN
    FUNCTION = "Error accessing Registry!"
    EXIT FUNCTION
  END IF

' ** Get the key value
  s = SIZEOF(buffer)
  RegQueryValueEx hKey, "Content Type", 0, %REG_SZ, buffer, s

' ** Close the registry
  RegCloseKey hKey

' ** Check to see if it's defined
  IF ISFALSE LEN(buffer) THEN
    buffer = "application/octet-stream"
  END IF

' ** Return the data
  FUNCTION = buffer

END FUNCTION

'---------------------------------------------------------------------------

FUNCTION PbMain()

  STDOUT GetMimeType(COMMAND$)

END FUNCTION



Sun, 01 Feb 2004 01:15:49 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Data Recovery SOURCE CODE ( SOURCE CODES of Professional Data Recovery Software )

2. Converting FORTRAN source code to C source code

3. The source and the sink different type with its source code

4. Find Forth source (was: 8031 Forth Source Code Needed)

5. Source Code Formatter - with source

6. ASM code public/private key cryptography source code

7. Source code for a Morse Code simulator

8. Open Source Code or Free code

9. Wanted: Source code for CODE-BAR39 generation

10. Translating fortran source code to matlab program (*.m) code

11. how to extract source code from code objects ?

12. Source code to diagram fortran code

 

 
Powered by phpBB® Forum Software