' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' * ' * Setting OLE Object flags (editing $OLEOBJECT fields) ' * ' * sample code from ' * LotusScript to Lotus C API Programmer Guide by Normunds Kalnberzins, (c) 2000-2003 ' * ' * http://www.ls2capi.com ' * ' * Author: Normunds Kalnberzins ' * ' * This code has been written as a sample to illustrate aspects of handling of Lotus C API from LotusScript ' * and may be reused, modified on full responsibility of the developer and provided this notice is preserved ' * ' * The author does not guaranty it to fit any particular purpose and it is up to the developer ' * to modify, test it and determine the limits of its applicability ' * ' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' * * * * * * * * START (Function library) [$OBJINFO] ' * * * * * * * * ' * ' * * * * * * * * START (Const) [MISC] ' * * * * * * * * ' * Const ITEM_OBJOLE = {$OLEOBJINFO} Const OFFSET_OLE_FLAGS = 34 Const OBJINFO_FLAGS_UPDATEFROMDOCUMENT = 32 Const ODS_DWORD = 1 Const ODS_WORD = 0 ' * * * * * * * * END (Const) [MISC] ' * * * * * * * * ' * * * * * * * * START (Type) [ BLOCKID] ' * * * * * * * * ' * Public Type BLOCKID pool As Long Block As Long End Type ' * * * * * * * * END (Type) [ BLOCKID] ' * * * * * * * * ' * * * * * * * * START (Declaration) [W32_OSLOADSTRING] ' * * * * * * * * ' * Declare Sub W32_OSLoadString Lib "nnotes.dll" Alias "OSLoadString" (Byval null1 As Long, Byval sError As Integer, Byval errstr As String, Byval lenstr As Integer) ' * * * * * * * * END (Declaration) [W32_OSLOADSTRING] ' * * * * * * * * ' * * * * * * * * START (Declaration) [W32_NSFITEMINFO] ' * * * * * * * * ' * Declare Function W32_NSFItemInfo Lib "nnotes.dll" Alias "NSFItemInfo" (Byval note_handle As Long, Byval item_name As Lmbcs String, Byval name_len As Integer, item_blockid As blockid, value_datatype As Integer, value_blockid As blockid, value_len As Long) As Integer ' * * * * * * * * END (Declaration) [W32_NSFITEMINFO] ' * * * * * * * * ' * * * * * * * * START (Declaration) [W32_ODSWRITEMEMOR ' * * * * * * * * ' * Declare Sub W32_ODSWriteMemory Lib "nnotes" Alias "ODSWriteMemory" (pSource As Long, Byval typeODS As Integer, pDest As Any, Byval Iterations As Integer ) ' * * * * * * * * END (Declaration) [W32_ODSWRITEMEMORY] ' * * * * * * * * ' * * * * * * * * START (Declaration) [W32_ODSREADMEMORY ' * * * * * * * * ' * Declare Sub W32_ODSReadMemory Lib "nnotes.dll" Alias "ODSReadMemory" (pSource As Long, Byval typeODS As Integer, pDest As Any, Byval Iterations As Integer ) Declare Function W32_OSLockObject Lib "nnotes.dll" Alias "OSLockObject" ( Byval handle As Long) As Long ' * * * * * * * * END (Declaration) [W32_ODSREADMEMORY] ' * * * * * * * * ' * * * * * * * * START (Declaration) [W32_OSUNLOCKOBJEC ' * * * * * * * * ' * Declare Sub W32_OSUnlockObject Lib "nnotes.dll" Alias "OSUnlockObject" ( Byval handle As Long) ' * * * * * * * * END (Declaration) [W32_OSUNLOCKOBJECT] ' * * * * * * * * ' * * * * * * * * START (Declaration) [W32_NSFITEMINFONE ' * * * * * * * * ' * Declare Function W32_NSFItemInfoNext Lib "nnotes" Alias "NSFItemInfoNext" (Byval note_handle As Long, Byval previous_item_blockid_pool As Long, Byval previous_item_blockid_block As Long, Byval item_name As String, Byval name_len As Integer, item_blockid As blockid, value_datatype As Integer, value_blockid As blockid, value_len As Long) As Integer ' * * * * * * * * END (Declaration) [W32_NSFITEMINFONEXT ' * * * * * * * * ' * * * * * * * * START (Method) [INITIALIZE] ' * * * * * * * * ' * Sub Initialize Dim s As New NotesSession Dim ndb As NotesDatabase Dim item_blockid As blockid, value_blockid As blockid Dim idatatype As Integer, value_len As Long Dim pBuff As Long Dim pBuff0 As Long Dim ole_flags As Long, new_flags As Long, old_blockid As blockid Dim irc As Integer Dim cnt As Integer Dim dcl As NotesDocumentcollection Dim doc As NotesDocument Set ndb = s.currentDatabase Set dcl=ndb.unprocesseddocuments Set doc = dcl.getfirstdocument Do While Not doc Is Nothing irc = W32_NSFItemInfo (doc.handle, ITEM_OBJOLE, Len(ITEM_OBJOLE), item_blockid , idatatype , value_blockid , value_len ) If irc<>0 Then Print getError(irc) Else Do While irc=0 pBuff = W32_OSLockObject (value_blockid.pool) + value_blockid.block pBuff0 = pBuff W32_ODSReadMemory pBuff0+OFFSET_OLE_FLAGS, ODS_dWORD, ole_flags, 1 ' read old flags new_flags = ole_flags Or OBJINFO_FLAGS_UPDATEFROMDOCUMENT W32_ODSWriteMemory pBuff+OFFSET_OLE_FLAGS, ODS_DWORD, new_flags, 1 ' write the new ones W32_OSUnLockObject (value_blockid.pool) Print "#" &Cnt, doc.noteid, "changed $OBJINFO flags from", ole_flags , "to", new_flags cnt = cnt + 1 old_blockid = item_blockid irc = W32_NSFItemInfoNext (doc.handle,old_blockid.pool , old_blockid.block , ITEM_OBJOLE, Len(ITEM_OBJOLE), item_blockid , idatatype , value_blockid , value_len ) Loop doc.~$dummy = 1 doc.removeitem "$dummy" ' just to force save doc.save True, True Set doc = dcl.getnextdocument (doc) End If Loop End Sub ' * * * * * * * * END (Method) [INITIALIZE] ' * * * * * * * * ' * * * * * * * * START (Method) [GETERROR] ' * * * * * * * * ' * Public Function getError (enum As Integer) As String Dim s As String*256 W32_OSLoadString 0, enum And &h03FFFFFFF, s, 256 getError = Strleft(s, Chr(0)) End Function ' * * * * * * * * END (Method) [GETERROR] ' * * * * * * * * ' * * * * * * * * END (Function library) [$OBJINFO] ' * * * * * * * *