You have two problems:
Your Function pointer needs to be declared "Win32" that will cause a crash with the stack.
You need to set the length of the dwLength member of the MEMORYSTATUS Type
This code is fixed and works
Hope this helps. Make sure if its Windows API to add "Win32" and make sure you fully read the API documents as there is often a size of length field on the type that needs to be set correctly.
Doug Stastny
Your Function pointer needs to be declared "Win32" that will cause a crash with the stack.
You need to set the length of the dwLength member of the MEMORYSTATUS Type
This code is fixed and works
Type MEMORYSTATUS Field dwLength:Int Field dwMemoryLoad:Int Field dwTotalPhys:Int Field dwAvailPhys:Int Field dwTotalPageFile:Int Field dwAvailPageFile:Int Field dwTotalVirtual:Int Field dwAvailVirtual:Int Method New() ' must set the legnth dwLength=SizeOf(MEMORYSTATUS) End Method EndType ' Must have "Win32" since windows API Global GlobalMemoryStatus(lpBuffer:Byte Ptr) "Win32" kernel32 = LoadLibraryA("kernel32.dll") If Kernel32 GlobalMemoryStatus = GetProcAddress(kernel32,"GlobalMemoryStatus") Else Notify("Impossible d'ouvrir la lib") EndIf Local Memoire:MEMORYSTATUS = New MEMORYSTATUS GlobalMemoryStatus(Memoire) Print "Total physical: "+(Memoire.dwTotalPhys/1024)+" Kb" Print "Available physical: "+(Memoire.dwAvailPhys/1024)+" Kb"
Hope this helps. Make sure if its Windows API to add "Win32" and make sure you fully read the API documents as there is often a size of length field on the type that needs to be set correctly.
Doug Stastny