par Droad » 29 Juil 2003 à 18:09
(Pour Win32 uniquement):Const NOTE_CLASS_FILTER = &H0200Const wAPIModule = "NNOTES" ' Windows/32Declare Private Function NIFFindDesignNote Lib wAPIModule Alias "NIFFindDesignNote" _( Byval hDB As Long, Byval S As String, Byval C As Integer, N As Long) As IntegerDeclare Private Function NSFDbClose Lib wAPIModule Alias "NSFDbClose" _( Byval DbHandle As Long) As IntegerDeclare Private Function OSPathNetConstruct Lib wAPIModule Alias "OSPathNetConstruct" _( Byval NullPort As Long, Byval Server As String, Byval FIle As String, Byval PathNet As String) As IntegerDeclare Private Function NSFDbOpen Lib wAPIModule Alias "NSFDbOpen" _( Byval PathName As String, DbHandle As Long) As IntegerSub Click(Source As Button) Dim session As New NotesSession, ws As New notesUIWorkspace Dim db As NotesDatabase Set db = session.CurrentDatabase Dim i As Integer Redim agentNames(Ubound(db.Agents)) As String Forall ag In db.agents agentNames(i) = ag.name i = i+1 End Forall Dim a As String a = ws.Prompt(PROMPT_OKCANCELLIST, "Agent", "Your choice:", agentNames(0), agentNames) If a = "" Then Exit Sub Dim adoc As NotesDocument Set adoc = GetAgentDocument(session.CurrentDatabase, a$) If adoc.HasItem("$MachineName") Then Messagebox "Machine Name: " & adoc.~$MachineName(0) Else Messagebox "No Machine Name" End IfEnd SubFunction GetAgentDocument(db As NotesDatabase, agent As String) As NotesDocument np$ = Space(1024) OSPathNetConstruct 0, db.Server, db.FilePath, np$ Dim hDB As Long NSFDbOpen np$, hDB If hDB = 0 Then Error 1000, "Can't open database" pt& = Instr(agent, "|") If pt& = 0 Then ti$ = Trim$(agent) Else ti$ = Trim$(Left$(agent, pt& - 1)) Dim nID As Long NIFFindDesignNote hDB, ti$, NOTE_CLASS_FILTER, nID If nID = 0 Then Error 1000, "Can't find agent " & ti$ NSFDbClose hDB Dim doc As NotesDocument Set doc = db.GetDocumentByID(Hex$(nID)) If Instr(doc.~$Flags(0), "f") = 0 Then Error 1000, ti$ & " is not an agent" Set GetAgentDocument = docEnd Function[%sig%]