Jump to content
Sign in to follow this  
dabus

Getting pst-format from its header

Recommended Posts

I want to update my little pst-check-tool that warns users before they blow up their outlook-pst-files. So I need to get the info if the pst-file is a 97-2002 type or above. So I played a bit with pst-headers and I I got this little udf. I think it works. May you test it or give me a hint that I'm done here? Thanks.

$Test=IsNewPST('D:\Temp\Test-2003.pst')
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Test = ' & $Test & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console



;===============================================================================
;
; Function Name:   IsNewPST
; Description::    Checks if file has a new pst-format (2003 and up)
; Parameter(s):    $File
; Requirement(s):  AutoIt 3.2 ++ (older may work too)
; Return Value(s): 1 - New, 0 - Old and @error = 1 - No pst, -1 No file
; Author(s):       dabus
;
;===============================================================================


Func IsNewPST($File) ; 
    $Handle = fileOpen($File,4)
    If $Handle = -1 Then 
        SetError(-1)
        Return('')
    Else
        $Header = fileread($Handle,11) 
        fileclose($Handle)
        $Header=StringTrimRight($Header, 1)
        $Header=StringTrimLeft($Header, 2)
        If StringLeft($Header, 8) <> '2142444E' Then 
            SetError(1)
            Return('')
        Else
            SetError(0)
            Return(StringRight($Header, 1))
        EndIf   
    EndIf   
EndFunc

Edit: Not anyone?

Edited by dabus

Share this post


Link to post
Share on other sites

Cool, thanks for testing.

Funny that it works as expected, since I just compared the first few characters and it seems like I got the right thing. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...