VBA Access: Código gernera que Access deje de responder
Cuando ejecuto este código, Access se cierra:
Option Compare Database Option Explicit Public vMemUso As String, vMemFisic As String, vMemDisp As String, vMemVirtual As String, vMemVirDisp As String, vMem As String, vSRes As String #If Depuracion Then '#If VBA7 And Win64 Then Public Declare PtrSafe Function GetSystemMetrics32 Lib "User32" _ Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long #Else Public Declare Function GetSystemMetrics32 Lib "User32" _ Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long #End If Type MEMORYSTATUS dwLength As Long dwMemoryLoad As Long dwTotalPhys As Long dwAvailPhys As Long dwTotalPageFile As Long dwAvailPageFile As Long dwTotalVirtual As Long dwAvailVirtual As Long End Type Type SYSTEM_INFO dwOemID As Long dwPageSize As Long lpMinimumApplicationAddress As Long lpMaximumApplicationAddress As Long dwActiveProcessorMask As Long dwNumberOrfProcessors As Long dwProcessorType As Long dwAllocationGranularity As Long dwReserved As Long End Type '#If Depuracion Then #If VBA7 And Win64 Then Public Declare PtrSafe Sub abGlobalMemoryStatus Lib "kernel32" Alias "GlobalMemoryStatus" (lpBuffer As MEMORYSTATUS) #Else Public Declare Sub abGlobalMemoryStatus Lib "kernel32" Alias "GlobalMemoryStatus" (lpBuffer As MEMORYSTATUS) #End If Sub GetSysInfo() Dim intMousePresent As Integer Dim strBuffer As String Dim intLen As Integer Dim MS As MEMORYSTATUS Dim SI As SYSTEM_INFO 'Set the length member before you call GlobalMemoryStatus MS.dwLength = Len(MS) abGlobalMemoryStatus MS vMem = "En uso:" & MS.dwMemoryLoad & "%" & vbCrLf & _ "Física Total en uso: " & Format(Format(Fix((MS.dwTotalPhys / 1024) / 1024) / 1024), "###,###") & " Gb." & vbCrLf & _ "Física Disponible en uso: " & Format(Format((Fix(MS.dwAvailPhys / 1024) / 1024) / 1024), "###,###") & " Gb." & vbCrLf & _ "Virtual Total en uso: " & Format(Format(Fix((MS.dwTotalVirtual / 1024) / 1024) / 1024), "###,###") & " Gb." & vbCrLf & _ "Virtual Disponible en uso: " & Format(Format((Fix(MS.dwAvailVirtual / 1024) / 1024) / 1024), "###,###") & " Gb." End Sub
Con el fin de obtener información básica del equipo donde se ejecuta la Base de Datos, llamo a este código para futuro diagnóstico. Pero me deja de responder y se cierra.
¿Dónde puede estar el error? ¡Aclaro! El código no es mío.
1 respuesta
Respuesta de Jacinto Trillo Jareño
2