Mark0
16-04-2008, 22:34
Here's a small demo that show how to use TrIDLib (http://mark0.net/code-tridlib-e.html) free edition from thinBasic.
TrIDLib is a DLL that make implementing the same filetype recognition abilities of TrID (http://mark0.net/soft-trid-e.html) on another app / tool a quick & easy task.
The usage of this edition of the library is free for personal, non commercial, reasearch or educational use.
The TrIDLib's web page is still being completed, as well as the documentation, but I think the sample source will be enough to get anyone interested up & running.
Bye!
' TrIDLib thinBasic Demo
' http://mark0.net/code-tridlib-e.html
uses "console"
#INCLUDE "TrIDLib-Const.inc"
#INCLUDE "TrIDLib-Funct.inc"
LOCAL ret AS LONG
LOCAL szBuf AS ASCIIZ * 4096
LOCAL ResNum AS LONG
LOCAL ResId AS LONG
LOCAL sOut$ as string
local MyFile$ as string
MyFile$ = "triddefs.trd" ' a random file to analyze
console_writeline "TrIDLib demo"
console_writeline
ret = TrID_LoadDefsPack("") ' load the definitions package (TrIDDefs.TRD) from current path
ret = TrID_SubmitFileA(MyFile$) ' submit the file
ret = TrID_Analyze() ' perform the analysis
IF ret THEN
ResNum = TrID_GetInfo(%TRID_GET_RES_NUM, 0, szBuf) ' get the number of results
IF ResNum = 0 THEN
console_writeline "Unknown filetype!"
ELSE
FOR ResId = 1 TO ResNum ' cycle trough the results
Ret = TrID_GetInfo(%TRID_GET_RES_FILETYPE, ResId, szBuf) ' get filetype descriptions
console_write STR$(ResId)& ":" & $TAB & szBuf
Ret = TrID_GetInfo(%TRID_GET_RES_FILEEXT, ResId, szBuf) ' get filetype extensions
console_write " (" & szBuf & ")"
Ret = TrID_GetInfo(%TRID_GET_RES_POINTS, ResId, szBuf) ' get the matching points
console_writeline " -" & STR$(Ret)
NEXT
END IF
ELSE
console_writeline "Error(s) occurred!"
END IF
console_writeline "Press any key."
CONSOLE_WAITKEY
Here's the output (the file analyzed is TrID's defs package):
TrIDLib demo
File: triddefs.trd
1: TrID defs package (TRD) - 22009
2: AOS File Format (AOS) - 10000
3: Generic RIFF container () - 4000
Press any key.
Bye!
TrIDLib is a DLL that make implementing the same filetype recognition abilities of TrID (http://mark0.net/soft-trid-e.html) on another app / tool a quick & easy task.
The usage of this edition of the library is free for personal, non commercial, reasearch or educational use.
The TrIDLib's web page is still being completed, as well as the documentation, but I think the sample source will be enough to get anyone interested up & running.
Bye!
' TrIDLib thinBasic Demo
' http://mark0.net/code-tridlib-e.html
uses "console"
#INCLUDE "TrIDLib-Const.inc"
#INCLUDE "TrIDLib-Funct.inc"
LOCAL ret AS LONG
LOCAL szBuf AS ASCIIZ * 4096
LOCAL ResNum AS LONG
LOCAL ResId AS LONG
LOCAL sOut$ as string
local MyFile$ as string
MyFile$ = "triddefs.trd" ' a random file to analyze
console_writeline "TrIDLib demo"
console_writeline
ret = TrID_LoadDefsPack("") ' load the definitions package (TrIDDefs.TRD) from current path
ret = TrID_SubmitFileA(MyFile$) ' submit the file
ret = TrID_Analyze() ' perform the analysis
IF ret THEN
ResNum = TrID_GetInfo(%TRID_GET_RES_NUM, 0, szBuf) ' get the number of results
IF ResNum = 0 THEN
console_writeline "Unknown filetype!"
ELSE
FOR ResId = 1 TO ResNum ' cycle trough the results
Ret = TrID_GetInfo(%TRID_GET_RES_FILETYPE, ResId, szBuf) ' get filetype descriptions
console_write STR$(ResId)& ":" & $TAB & szBuf
Ret = TrID_GetInfo(%TRID_GET_RES_FILEEXT, ResId, szBuf) ' get filetype extensions
console_write " (" & szBuf & ")"
Ret = TrID_GetInfo(%TRID_GET_RES_POINTS, ResId, szBuf) ' get the matching points
console_writeline " -" & STR$(Ret)
NEXT
END IF
ELSE
console_writeline "Error(s) occurred!"
END IF
console_writeline "Press any key."
CONSOLE_WAITKEY
Here's the output (the file analyzed is TrID's defs package):
TrIDLib demo
File: triddefs.trd
1: TrID defs package (TRD) - 22009
2: AOS File Format (AOS) - 10000
3: Generic RIFF container () - 4000
Press any key.
Bye!