
Access
Obtener el nombre de la computadora
![]() |
![]() |
Ejemplos
en una expresión:
«El nombre de su computadora es ‘» & apiGetComputerName() & «‘»
como fuente de control:
=apiGetComputerName()
Código
VBA7 está disponible para Access 2010 y versiones posteriores.
#If VBA7 Then Private Declare PtrSafe Function apiGetComputerName _ Lib "kernel32" Alias "GetComputerNameA" _ (ByVal lpBuffer As String, nSize As Long) _ As Long #Else Private Declare Function apiGetComputerName _ Lib "kernel32" Alias "GetComputerNameA" _ (ByVal lpBuffer As String, nSize As Long) _ As Long #End If Public Function GetComputerName( _ ) As String Dim sBuffer As String _ , nLen As Long _ , nSize As Long nLen = 16 sBuffer = String$(nLen, 0) nSize = apiGetComputerName(sBuffer, nLen) If nSize 0 Then GetComputerName = Left$(sBuffer, nLen) Else GetComputerName = "" End if End Function
‘ referencia: función GetComputerNameA
Compartir
Comparte con otros… aquí está el enlace para copiar: