Red box with c-api call on NSFDbOpenExtended

Hi,

I try a db-purge to get rid off deletionstubs that are older than the cutoff-date.

It should fix some issues on several clients that are rolled out, so we need a solution that works without user-interaction (doing it manually works without problems.)

So I worked on a c-api call that should be excecuted in a Postopen-event of a form. But my 6.5.6-client always crashes with a redbox at the same line. I tried several changes, but all with the same result. I stripped the code to the below example in an agent.

The crash appears when the function W32_NSFDbOpenExtended is called.

Because I’m not experienced, I guess some error in the handling of datatypes, but I was not able to fix it.

Has anybody an advice?

Thanks and regards

Joerg

Option Public

Option Declare

Const NULLHANDLE = &H0

Const DBOPEN_PURGE% = &H0002 '### purge deletion stubs

'** Error code masks

Const ERR_MASK = &H3fff

Const PKG_MASK = &H3f00

Const ERRNUM_MASK = &H00ff

Public Type TIMEDATE

innards(1) As Long

End Type

Declare Function W32_NSFDbOpenExtended Lib “nnotes.dll” Alias “NSFDbOpenExtended” ( Byval dbName As String, _

options As Long, names As String, modData As TIMEDATE, hdb As Long, dataDate As TIMEDATE, nonDataDate As TIMEDATE) As Integer

Declare Function W32_NSFDbClose Lib “nnotes.dll” Alias “NSFDbClose” ( Byval hdb As Long ) As Integer

Declare Function W32_OSCurrentTIMEDATE Lib “nnotes.dll” Alias “OSCurrentTIMEDATE” (td As TIMEDATE) As Integer

Declare Function W32_TimeDateAdjust Lib “nnotes.dll” Alias “TimeDateAdjust” (td As TIMEDATE, Byval seconds As Long, _

Byval minutes As Long, Byval hours As Long, Byval days As Long, Byval months As Long, Byval years As Long) As Integer

Sub Initialize

Dim s As NotesSession

Dim Tdb As String

Dim hdb As Long

Dim status As Integer

Dim tdBegin As TIMEDATE

Dim tdData As TIMEDATE

Dim tdNonData As TIMEDATE



Set s = New NotesSession

Tdb$ = s.CurrentDatabase.FilePath

Call W32_OSCurrentTimeDate(tdBegin)

Call W32_TimeDateAdjust(tdBegin, 0, 0, 0, 0, 0, -99)



status% = W32_NSFDbOpenExtended( Tdb$, DBOPEN_PURGE%, NULLHANDLE, tdBegin, hdb&, tdData, tdNonData)



If ( status% <> 0 ) Then Print("Error occured")

Call W32_NSFDbClose(hdb&)

End Sub

Subject: red box with c-api call on NSFDbOpenExtended

When you change the declaration of the C-API call to this all works fine:

Declare Function W32_NSFDbOpenExtended Lib “nnotes.dll” Alias “NSFDbOpenExtended” ( Byval dbName As String, _

options As Long, Byval names As Long, modData As TIMEDATE, hdb As Long, dataDate As TIMEDATE, nonDataDate As TIMEDATE) As Integer

Please remember that a HANDLE is always of type long.

Subject: That was the solution, thanks a lot!