par Michael DELIQUE » 06 Nov 2007 à 17:19
D'après un code de Julian Robichaux
- Code : Tout sélectionner
Public Function StublessDelete_API(wDoc As NotesDocument) As Integer
%REM
'variableAPI pour la fonction StublessDelete_API
Declare Function OSPathNetConstruct Lib "nnotes.dll" (Byval wnbPortName As Integer, Byval wserverName As String, Byval wfileName As String, Byval wpathName As String) As Integer
Declare Function NSFNoteDelete Lib "nnotes.dll" (Byval wnbHandleDB As Long, Byval wnbNoteID As Long, Byval wnbFlags As Integer) As Integer
Declare Function NSFDbClose Lib "nnotes.dll" (Byval wnbHandleDB As Long) As Integer
Declare Function NSFDbOpen Lib "nnotes.dll" (Byval wdbName As String, wnbRethDB As Long) As Integer
%END REM
'Déclaration Variables
Dim pathName As String*256
Dim nbHandleDB As Long
Dim nbResult As Integer
Dim nbConvertID As Long
Const UPDATE_NOSTUB = 0512
Const UPDATE_FORCE = 0001
On Error Goto ErreurHandle
If wDoc Is Nothing Then
Error 9999,"wDoc is Nothing"
End If
StublessDelete_API = True
'ouverture la base de document
Call OSPathNetConstruct(0, wDoc.ParentDatabase.Server, wDoc.ParentDatabase.FilePath, pathName)
nbResult = NSFDbOpen(pathName, nbHandleDB)
If nbResult <> 0 Then
Error 9999,"Database inaccessible : "+Cstr(nbResult )
Exit Function
End If
'conversion du notesID
nbConvertID = Clng(Val("&H" & Cstr(wDoc.NoteID))) And &H7FFFFFFF
'suppression du document
nbResult = NSFNoteDelete(nbHandleDB, nbConvertID, UPDATE_NOSTUB Or UPDATE_FORCE)
If nbResult <> 0 Then
Error 9999,"Suppression impossible : "+Cstr(nbResult )
Exit Function
End If
Call NSFDbClose(nbHandleDB)
Exit Function
ErreurHandle:
Msgbox "("+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
StublessDelete_API = False
Exit Function
End Function
Cordialement
Michael (SMS-Phobique)
----------------------------
"La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi."
Albert EINSTEIN