Lotus Notes: Acessando uma dll através do LotusScript

From Wiki
Jump to navigation Jump to search

Como fazer para utilizar função que fica em DLL do Windows através do Lotus Notes?

Vamos exemplificar com o seguinte código abaixo, que pega o usuário do Windows logado

1) Crie uma agente adicione o seguinte em Declarations

'Declarations Script de Auditoria - Inicio
Declare Function win32GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (Byval lpBuffer As String, nSize As Long) As Long 

2) Crie a função getCurrentOSUser

Function getCurrentOSUser As String
  Dim username As String ' receives name of the user
  Dim slength As Long ' length of the string
  Dim retval As Long ' return value
  
  username = Space(255) ' room for 255 characters
  slength = 255 ' initialize the size of the string
  
  retval = win32GetUserName(username, slength) ' slength is now the length of the returned string
  username = Left(username, slength - 1) ' extract the returned info from the buffer
  
  getCurrentOSUser = username
End Function

Basta agora chamar a função no seu código

Ver também