VBA problem when recording sound using Sound Recorder (> 4 Gig mem

P

Peter

I jave a VBA application in Word that records sound using Sound recorder.
UNFORTUNATELY Sound Recorder does not work correctrly in a machine which has
more than 4 Gig of memory
http://support.microsoft.com/default.aspx/kb/284893?p=1

Can I test the amount of memory using VBA in Word so that I can give the
user an appropriate message?

Any assistance very gratefully received,
PeterEvans
 
K

Karl E. Peterson

Karl said:
Absolutely, using the GlobalMemoryStatusEx API.

See: http://vb.mvps.org/samples/MemStatus

That might be more confusing that it needs to be. Here's the "simple"
answer (indented to highlight wordwrap):

' Win32 API Declarations
Private Declare Function GlobalMemoryStatusEx Lib "kernel32"
(lpBuffer As MEMORYSTATUSEX) As Long
Private Type MEMORYSTATUSEX
dwLength As Long
dwMemoryLoad As Long
ullTotalPhys As Currency
ullAvailPhys As Currency
ullTotalPageFile As Currency
ullAvailPageFile As Currency
ullTotalVirtual As Currency
ullAvailVirtual As Currency
ullAvailExtendedVirtual As Currency
End Type

Public Function InstalledMemory() As Variant
Dim ms As MEMORYSTATUSEX
Const CurrFactor As Long = 10000
ms.dwLength = Len(ms)
Call GlobalMemoryStatusEx(ms)
InstalledMemory = ms.ullTotalPhys * CurrFactor
End Function

Public Function Over4g() As Boolean
Over4g = (InstalledMemory > (4 * 1024 ^ 3))
End Function

Here, just calling Over4g() will tell you whether the machine has more
than 4gb of installed RAM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top