hast du den Anhang nicht gesehen da sind Beispiele für beide Funktionen vorhanden.
Nochmal als Code included.
(Options)
Option Public
Option Declare
(Declarations)
Type BLOCKID
hPool As Long
Block As Integer
End Type
Type TIMEDATE
Innards(1) As Long
End Type
Type FTINDEX 'Type used to pass the options to set in the index
Indexed As Integer 'Create index true / false
IndexAttachments As Integer 'Index attachments true / false
IndexAttachmentsFormat As Integer 'Index format true = raw text only, false = binary
EncryptedFields As Integer 'index encrypted fields true / false
IndexBreaks As Integer 'index sentence and paragraph breaks true /false
CaseSensitive As Integer 'case sensitive index true / false
UpdateFrequency As Integer 'update frequency : 0 = Daily | 1 = Scheduled | 2 = Hourly | 3 = Immediate
LastIndexedOn As String 'last index date/time
End Type
Const ERR_MASK = &H3FFF
Declare Private Function OSPathNetConstruct Lib "nnotes.dll" Alias "OSPathNetConstruct" (Byval zP As Long, Byval Server As String, Byval FilePath As String, Byval N As String) As Integer
Declare Private Function NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" (Byval P As String, hDB As Long) As Integer
Declare Private Function NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" (Byval hDB As Long) As Integer
Declare Function NSFDbGetExtendedInfo Lib "nnotes.dll" Alias "NSFDbGetExtendedInfo" (Byval hDB As Long, hB As BLOCKID) As Integer
Declare Function NSFDbSetExtendedInfo Lib "nnotes.dll" Alias "NSFDbSetExtendedInfo" (Byval hDB As Long, Byval hB As Long) As Integer
Declare Private Function FTGetLastIndexTime Lib "nnotes.dll" Alias "FTGetLastIndexTime" (Byval hDB As Long, T As TIMEDATE) As Integer
Declare Private Function OSLockObject Lib "nnotes.dll" Alias "OSLockObject" (Byval hM As Long) As Long
Declare Private Sub OSUnlockObject Lib "nnotes.dll" Alias "OSUnlockObject" (Byval hM As Long)
Declare Private Function OSMemFree Lib "nnotes.dll" Alias "OSMemFree" (Byval hM As Long) As Integer
Declare Function ConvertTIMEDATEToText Lib "nnotes.dll" Alias "ConvertTIMEDATEToText" (Byval zI As Long, Byval zT As Long, T As TIMEDATE, Byval S As String, Byval nS As Integer, nT As Integer) As Integer
Declare Private Sub Peek Lib "MSVCRT" Alias "memcpy" (D As Any, Byval P As Long, Byval N As Long)
Declare Private Sub Poke Lib "MSVCRT" Alias "memcpy" (Byval D As Long, D As Any, Byval N As Long)
Declare Function NSFDbSetOptions Lib "nnotes.dll" Alias "NSFDbSetOptions" _
(Byval hDB As Long, Byval dboptions As Long, Byval optionmask As Long ) As Integer
Declare Function OSLoadString Lib "nnotes.dll" Alias "OSLoadString" (_
Byval hModule As Long, _
Byval Status As Integer, _
Byval retBuffer As String, _
BufferLength As Integer) As Integer
Const DBOPTION_FT_INDEX = &H00000001 'Enable full text indexing
Function SetFTIndexInfo(Server As String, FilePath As String, Index As FTINDEX) As Integer
REM ==============================================================================
REM This function will set the extended info of a database to create an index
REM Parameters:
REM Server : name of the server where the database is located
REM FilePath : file path where the database is located (directory and filename)
REM FTINDEX : structure with detailed information of the index to be created
REM .IndexAttachments : true = yes, false = no
REM .IndexAttachmentsFormat : true = binary, false = normal
REM .EncryptedFields : true = index encrypted fields, false = don't index encrypted fields
REM .IndexBreaks : true = index sentence and paragraph breaks, false = index words only
REM .CaseSensitive : true = case sensitive index on, false = case sensitive index off
REM .UpdateFrequency : 0 = Daily | 1 = Scheduled | 2 = Hourly | 3 = Immediate
REM ==============================================================================
Const DLGTITLE = "SetFTIndexInfo"
On Error Goto ErrorHandler
REM ***** Define local variables *****
Dim FullPath As String
Dim hDB As Long
Dim idx As Integer
Dim opt As Integer
Dim frq As Integer
Dim p As Long
Dim hB As BlockID
Dim rc As Integer
Dim strError As String
REM ***** If all went well, return true *****
SetFTIndexInfo = True
REM ***** Construct Full Path to the database *****
FullPath = Space(1024)
rc = OSPathNetConstruct (0, Server, FilePath, FullPath)
If rc And ERR_MASK = 0 Then
strError = String(255, " ")
Call OSLoadString(0, rc, strError, 255)
Messagebox "Kan path naar database niet creëren." & Chr(10) & "Reden: " & strError, 0, DLGTITLE
SetFTIndexInfo = False
Exit Function
End If
REM ***** Open Database through C API *****
rc = NSFDbOpen (FullPath, hDB)
If rc And ERR_MASK = 0 Then
strError = String(255, " ")
Call OSLoadString(0, rc, strError, 255)
Messagebox "Kan database niet openen." & Chr(10) & "Reden: " & strError, 0, DLGTITLE
SetFTIndexInfo = False
Exit Function
End If
'If we can't open the database exit
If hDB = 0 Then
SetFTIndexInfo = False
Exit Function
End If
REM ***** Compute values to set *****
'Check if database needs to be indexed
If Index.Indexed Then
idx = 1
'set database options so the index will be created
rc = NSFDbSetOptions(hDB, DBOPTION_FT_INDEX, DBOPTION_FT_INDEX)
If rc And ERR_MASK <> 0 Then
strError = String(255, " ")
Call OSLoadString(0, rc, strError, 255)
Messagebox "Kan index niet creëren." & Chr(10) & "Reden: " & strError, 0, DLGTITLE
SetFTIndexInfo = False
Exit Function
End If
Else
idx = 0
End If
'Index attachments
If Index.IndexAttachments Then
opt = opt Or &H20
Else
opt = opt And &HDF
End If
'Index binary attachments
If Index.IndexAttachmentsFormat Then
opt = opt Or &H80
Else
opt = opt And &H7F
End If
'Index encrypted fields
If Index.EncryptedFields Then
opt = opt Or &H40
Else
opt = opt And &HBF
End If
'Index sentence and paragraph breaks
If Index.IndexBreaks Then
opt = opt Or &H10
Else
opt = opt And &HEF
End If
'Index case-sensitive
If Index.CaseSensitive Then
opt = opt Or &H02
Else
opt = opt And &HFD
End If
'set update frequency
frq = Index.UpdateFrequency
REM ***** Set new attributes *****
rc = NSFDbGetExtendedInfo (hDB, hB)
If rc And ERR_MASK = 0 Then
strError = String(255, " ")
Call OSLoadString(0, rc, strError, 255)
Messagebox "Kan extended info van database niet lezen." & Chr(10) & "Reden: " & strError, 0, DLGTITLE
SetFTIndexInfo = False
Exit Function
End If
If Not hB.hPool = 0 Then
p = OSLockObject(hB.hPool) + hB.Block
Poke p + 2, idx , 2
Poke p + 6, opt , 2
Poke p + 8, frq , 2
Else
Call NSFDbClose (hDB)
Exit Function
End If
Call OSUnlockObject (hB.hPool)
rc = NSFDbSetExtendedInfo (hDB, hB.hPool)
If rc And ERR_MASK = 0 Then
strError = String(255, " ")
Call OSLoadString(0, rc, strError, 255)
Messagebox "Kan extended info database niet wijzigen." & Chr(10) & "Reden: " & strError, 0, DLGTITLE
SetFTIndexInfo = False
Exit Function
End If
REM ***** Free memory and close database *****
NSFDbClose hDB
Exit Function
ErrorHandler:
Messagebox "SetFTIndexInfo: " & Err & " - " & Error$ & " in line " & Erl
SetFTIndexInfo = False
Resume Next
End Function
Function GetFTIndexInfo(Server As String, FilePath As String, Index As FTINDEX) As Integer
Const DLGTITLE = "GetFTIndexInfo"
Dim FullPath As String
Dim rc As Integer
Dim strError As String
Dim hDB As Long
Dim hB As BLOCKID
Dim p As Long
Dim idx As Integer
Dim opt As Integer
Dim frq As Integer
Dim l As Integer
Dim LastIndexedOn As String
FullPath = Space(1024)
rc = OSPathNetConstruct (0, Server, FilePath, FullPath)
NSFDbOpen FullPath, hDB
If hDB = 0 Then Exit Function
rc = NSFDbGetExtendedInfo (hDB, hB)
If rc And ERR_MASK = 0 Then
strError = String(255, " ")
Call OSLoadString(0, rc, strError, 255)
Messagebox "Kan extended info van database niet lezen." & Chr(10) & "Reden: " & strError, 0, DLGTITLE
GetFTIndexInfo = False
Exit Function
End If
If hB.hPool = 0 Then
NSFDbClose hDB
Exit Function
Else
p& = OSLockObject(hB.hPool) + hB.Block
Peek idx, p& + 2, 2
Peek opt, p& + 6, 2
Peek frq, p& + 8, 2
OSUnlockObject hB.hPool
End If
Dim T As TimeDate
FTGetLastIndexTime hDB, T
If Not T.Innards(0) = 0 Then
LastIndexedOn = Space(256)
ConvertTIMEDATEToText 0, 0, T, LastIndexedOn, 256, L
LastIndexedOn = Left$(LastIndexedOn, L)
End If
NSFDbClose hDB
'Check if database is indexed
If idx% = 0 Then
Index.Indexed="0"
Else
Index.Indexed="1"
Index.LastIndexedOn = LastIndexedOn
End If
If (opt% And &H20) Then
Index.IndexAttachments="1"
Else
Index.IndexAttachments="0"
End If
If (opt% And &H80) Then
Index.IndexAttachmentsFormat="1"
Else
Index.IndexAttachmentsFormat="0"
End If
If (opt% And &H40) Then
Index.EncryptedFields="1"
Else
Index.EncryptedFields="0"
End If
If (opt% And &H10) Then
Index.IndexBreaks="1"
Else
Index.IndexBreaks="0"
End If
If (opt% And &H02) Then
Index.CaseSensitive="1"
Else
Index.CaseSensitive="0"
End If
'Get update frequency
Index.UpdateFrequency=Cstr(frq%)
End Function
'The SetFTIndex function will set the properties of the index in the database. The indexer task on the server will then create the index later.
'The GetFTIndex function will return a structure (as defined in the type FTINDEX) containing all details of the index of the passed database.