Option Public
Type API_TIMEDATE
Innards(1) As Long
End Type
Type API_ORIGINATORID
File As Double
Note As Double
Sequence As Long
SequenceTime As API_TIMEDATE
End Type
Type API_TIME
Year As Long
Month As Long
Day As Long
Weekday As Long
Hour As Long
Minute As Long
Second As Long
hundredth As Long
dst As Long
zone As Long
GM As API_TIMEDATE
End Type
Declare Sub NSFNoteGetInfo Lib "nnotes" Alias "NSFNoteGetInfo" ( _
ByVal note_handle As Long, ByVal note_member As Long, value_ptr As Any)
Declare Function TimeGMToLocal Lib "nnotes" Alias "TimeGMToLocal" ( _
dtTime As API_TIME ) As Long
Const NOTE_OID = 2
Type BlockID
hPool As Long
Block As Integer
End Type
Const wAPIModule = "NNOTES" ' Windows/32
Declare Function OSPathNetConstruct Lib wAPIModule Alias "OSPathNetConstruct" _
( ByVal zP As Long, ByVal S As String, ByVal F As String, ByVal P As String) As Integer
Declare Function NSFDbOpen Lib wAPIModule Alias "NSFDbOpen" _
( ByVal P As String, hDB As Long) As Integer
Declare Function NSFDbClose Lib wAPIModule Alias "NSFDbClose" _
( ByVal hDB As Long) As Integer
Declare Function NSFNoteOpen Lib wAPIModule Alias "NSFNoteOpen" _
( ByVal hDB As Long, ByVal N As Long, ByVal F As Integer, hNT As Long) As Integer
Declare Function NSFNoteClose Lib wAPIModule Alias "NSFNoteClose" _
( ByVal hNT As Long) As Integer
Declare Function OSMemFree Lib wAPIModule Alias "OSMemFree" _
( ByVal hM As Long) As Integer
Declare Function OSLoadString Lib wAPIModule Alias "OSLoadString" _
( ByVal hM As Long, ByVal S As Integer, ByVal B As String, ByVal nB As Integer) As Integer
Declare Function OSLockObject Lib wAPIModule Alias "OSLockObject" _
( ByVal hM As Long) As Long
Declare Sub OSUnlockObject Lib wAPIModule Alias "OSUnlockObject" _
( ByVal hM As Long)
Declare Function NSFItemInfo Lib wAPIModule Alias "NSFItemInfo" _
( ByVal hNT As Long, ByVal N As String, ByVal nN As Integer, iB As BlockID _
, D As Integer, vB As BlockID, nV As Long) As Integer
Declare Function NSFItemInfoNext Lib wAPIModule Alias "NSFItemInfoNext" _
( ByVal hNT As Long, ByVal hP As Long, ByVal B As Integer, ByVal N As String, ByVal nN As Integer, iB As BlockID _
, D As Integer, vB As BlockID, nV As Long) As Integer
Declare Sub NSFItemQuery Lib wAPIModule Alias "NSFItemQuery" _
( ByVal hNT As Long, ByVal hP As Long, ByVal B As Integer _
, ByVal zN As Long, ByVal mN As Integer, nN As Integer _
, F As Integer, T As Integer, vB As BlockID, nV As Long)
Declare Function ConvertTIMEDATEToText Lib wAPIModule Alias "ConvertTIMEDATEToText" _
( ByVal F As Long, ByVal T As Long, ByVal P As Long, ByVal S As String _
, ByVal nS As Integer, rS As Integer) As Integer
Declare Function NSFDbGetObjectSize Lib wAPIModule Alias "NSFDbGetObjectSize" _
( ByVal hDB As Long, ByVal oID As Long, ByVal T As Integer, S As Long _
, C As Integer, P As Integer) As Integer
Declare Sub Peek Lib "KERNEL32" Alias "RtlMoveMemory" _
( D As Any, ByVal P As Long, ByVal N As Long)
Declare Sub PeekString Lib "KERNEL32" Alias "RtlMoveMemory" _
( ByVal D As String, ByVal P As Long, ByVal N As Long)
Declare Sub CopyLS Lib "KERNEL32" Alias "RtlMoveMemory" _
( D As Any, P As Any, ByVal N As Long)
Sub Initialize
End Sub
Function getObjectId(doc As NotesDocument) As String
getobjectId = ""
Const tz = "~~"
Dim s As String
Dim i As Long
s = ""
i = 0
Dim db As NotesDatabase
Set db = doc.ParentDatabase
dp$ = String(1024, " ")
OSPathNetConstruct 0, db.Server, db.FilePath, dp$
Dim hDB As Long
NSFDbOpen dp$, hDB
If hDB = 0 Then Exit function
Dim hNT As Long
NSFNoteOpen hDB, CLng("&H" & doc.NoteID), 0, hNT
If Not hNT = 0 Then
Dim iB As BlockID, vB As BlockID
NSFItemInfo hNT, "$FILE", 5, iB, dt%, vB, nV&
While Not nV& = 0
i = i + 1
NSFItemQuery hNT, iB.hPool, iB.Block, 0, 0, 0, f%, dt%, vB, nV&
If s > "" Then
s = s & tz
End If
s = s & "[$FILE Item=" & CStr(i) & "|" & PeekObjectId(f%, vB, hDB) & "]"
NSFItemInfoNext hNT, iB.hPool, ib.Block, "$File", 5, iB, dt%, vB, nV&
Wend
End If
getObjectId = s
NSFNoteClose hNT
NSFDbClose hDB
End Function
Function PeekObjectId(f%, vB As BlockID, hDB As Long) As String
Const itemflags = "SIGN SEAL SUMMARY &H08 &H10 READWRITERS NAMES " _
& "&H80 PLACEHOLDER PROTECTED READERS &H0800 UNCHANGED"
PeekObjectId = ""
If vB.hPool = 0 Then Exit function
p& = OSLockObject(vB.hPool) + vB.Block
' $FILE Attachment name --> fname$
Peek nF&, p& + 8, 2
fname$ = String$(nF&, " ")
PeekString fname$, p& + 38, nF&
' Object-ID
Peek oID&, p& + 4, 4
OSUnlockObject vB.hPool
PeekObjectId = "filename=" & fname$ & "|Object-ID=" & Right$("00000000" & Hex$(oID&),8)
End Function
In meinem Agenten (den ich momentan nur vom Client ausführe), kann ich dann einfach mit
die Object-ID's von allen $FILE-Items eines Notesdokumentes auslesen. Die Formatierung des Rückgabewertes paßt sich dem anderen Log-Drumherum an, also bitte nicht wundern.