Voilà pour trouver la mémoire RAM d'un PC, mais un pote m'a dit qu'il n'avait que 512 mo mais que le soft lui trouvait 2047 mo..
étrange non ?
pourriez vous tester et me dire si ça marche.
Soit c'est une quiche qui a confondu la mémoire de sa carte graphique, soit cette procédure affiche la taille utilisable par XP et non la qté de RAM contenue du dans le pc
The GlobalMemoryStatus function obtains information about the system's current usage of both physical and virtual memory.
To obtain information about the extended portion of the virtual address space, or if your application may run on computers with more than 4 GB of main memory, use the GlobalMemoryStatusEx function.
Parameters
lpBuffer
[out] Pointer to a MEMORYSTATUS structure. The GlobalMemoryStatus function stores information about current memory availability into this structure.
Return Values This function does not return a value
http://purebasic.developpez.com/
Je ne réponds à aucune question technique en PV, utilisez le forum, il est fait pour ça, et la réponse peut profiter à tous.
; The MEMORYSTATUS Structure contains information about current memory availability. The GlobalMemoryStatus function uses this Structure.
;
; typedef struct _MEMORYSTATUS { // mst
; DWORD dwLength; // sizeof(MEMORYSTATUS)
; DWORD dwMemoryLoad; // percent of memory in use
; DWORD dwTotalPhys; // bytes of physical memory
; DWORD dwAvailPhys; // free physical memory bytes
; DWORD dwTotalPageFile; // bytes of paging file
; DWORD dwAvailPageFile; // free bytes of paging file
; DWORD dwTotalVirtual; // user bytes of address space
; DWORD dwAvailVirtual; // free user bytes
;
; } MEMORYSTATUS, *LPMEMORYSTATUS;
;
;
; Members
;
; dwLength
;
; Indicates the size of the Structure. The calling process should set this member prior To calling GlobalMemoryStatus.
;
; dwMemoryLoad
;
; Specifies a number between 0 And 100 that gives a general idea of current memory utilization, in which 0 indicates no memory use And 100 indicates full memory use.
;
; dwTotalPhys
;
; Indicates the total number of bytes of physical memory.
;
; dwAvailPhys
;
; Indicates the number of bytes of physical memory available.
;
; dwTotalPageFile
;
; Indicates the total number of bytes that can be stored in the paging file. Note that this number does Not represent the actual physical size of the paging file on disk.
;
; dwAvailPageFile
;
; Indicates the number of bytes available in the paging file.
;
; dwTotalVirtual
;
; Indicates the total number of bytes that can be described in the user mode portion of the virtual address space of the calling process.
;
; dwAvailVirtual
;
; Indicates the number of bytes of unreserved And uncommitted memory in the user mode portion of the virtual address space of the calling process.
;
;
mem=GlobalMemoryStatus_(@info.MEMORYSTATUS)
mem2=mem/1024/1024
memoire$=Str(mem2)+" Mo"
Debug memoire$
Debug mem
Debug "**********************************"
Debug info\dwlength; // sizeof(MEMORYSTATUS)
Debug info\dwMemoryLoad; // percent of memory in use
Debug info\dwTotalPhys; // bytes of physical memory
Debug info\dwAvailPhys; // free physical memory bytes
Debug info\dwTotalPageFile; // bytes of paging file
Debug info\dwAvailPageFile; // free bytes of paging file
Debug info\dwTotalVirtual; // user bytes of address space
Debug info\dwAvailVirtual; // free user bytes
Petit historique des liens consacrés à la structure MemoryStatus : LSI LSI LSI Jacobus Droopy
@PAPIPP
Très cool d'avoir posté la doc complète. Merci. En la traduisant, j'ai constaté qu'il est recommandé de spécifier la taille de la structure avant d'appeler la fonction.
; _______________________________________________________
; Détermination des différentes taille mémoires
; Ollivier
; Libre
; ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
; _______________________________________________________
; ETAT MEMOIRE MEMOIRES DISPO DISPONIBLE
; STAT MEMORY MEMORIES AVAILABLE (comme ça je le retrouvrai !)
; ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
;
; La fonction GlobalMemoryStatus() nécessite la
; structure MEMORYSTATUS contenant les infos sur la
; mémoire courante.
;
; (Process appelant = Programme qui appelle la fonction)
;
; dwLength.L 1) sizeof(MEMORYSTATUS)
; dwMemoryLoad.L 2) percent of memory in use
; dwTotalPhys.L 3) bytes of physical memory
; dwAvailPhys.L 4) free physical memory bytes
; dwTotalPageFile.L 5) bytes of paging file
; dwAvailPageFile.L 6) free bytes of paging file
; dwTotalVirtual.L 7) user bytes of address space
; dwAvailVirtual.L 8) free user bytes
;
; 1) dwLength : Indique la taille de la structure
; Le process appelant doit spécifier cette valeur
; AVANT d'exécuter la fonction GlobalMemoryStatus()
;
; 2) dwMemoryLoad : Renvoie le pourcentage de mémoire
; utilisée.
; 0% = Mémoire complètement dispo
; 100% = Mémoire complètement saturée
;
; 3) dwTotalPhys : Taille totale de la mémoire physique
; (en bytes)
;
; 4) dwAvailPhys : Taille de la mémoire physique
; disponible (en bytes)
;
; 5) dwTotalPageFile : Indique la taille mémoire
; maximum (en octets) supportée par le fichier de
; pagination.
; Nota : cette valeur ne correspond pas à la taille
; physique actuelle sur disque du fichier de
; pagination.
;
; 6) dwAvailPageFile : Indique la taille mémoire
; disponible dans le fichier de pagination.
;
; 7) dwTotalVirtual : Indique la taille mémoire
; virtuelle théoriquement allouable par le process
; appelant
;
; 8) dwAvailVirtual : Indique la taille mémoire
; virtuelle dispo pour le process appelant
;
Define MemInfo.MEMORYSTATUS
Define MemInfoWin.L ; Handle de la fenêtre d'affichage
Define MemInfoGgt.L ; N° du gadget d'affichage
Define Comment.S ; Commentaires explicatifs (pour chaque item)
Define Value.S ; Valeur affichée (Idem)
Define LValue.L ; Valeur extraite de la foncT API (Idem)
Define W.L ; Largeur interne de la fenêtre
Define H.L ; Hauteur interne de la fenêtre
Define B.L ; Taille (pixel) des marges de cadrage du gadget
B = 16
PokeL(MemInfo, SizeOf(MEMORYSTATUS) )
If GlobalMemoryStatus_(MemInfo)
W = 620
H = 192
MemInfoWin = OpenWindow(-1, 0, 0, W, H, "Infos mémoire", $CF0001)
If MemInfoWin
CreateGadgetList(WindowID(MemInfoWin) )
MemInfoGgt = ListIconGadget(-1, B, B, W - B << 1, H - B << 1, "Nom", 384)
AddGadgetColumn(MemInfoGgt, 1, "Valeur", 200)
Restore MemInfoData
For I = 1 To 7
Read Comment
LValue = PeekL(MemInfo + I << 2)
Value = Str(LValue)
If I = 1
Value + "%"
Else
Value = Str(LValue >> 20) + "Mo (" + Value + " octets)"
EndIf
AddGadgetItem(MemInfoGgt, -1, Comment + Chr(10) + Value )
Next I
Repeat
Until WaitWindowEvent() = 16
CloseWindow(MemInfoWin)
Else
MessageRequester("Erreur", "Problème d'affichage !")
EndIf
Else
MessageRequester("Erreur", "Impossible d'obtenir les infos concernant la mémoire !")
EndIf
DataSection
MemInfoData:
Data.S "Pourcentage représentatif de la mémoire utilisée."
Data.S "Taille totale de la mémoire physique"
Data.S "Taille de la mémoire physique disponible"
Data.S "Taille mémoire maximum supportée par le fichier de pagination."
Data.S "Taille mémoire disponible dans le fichier de pagination"
Data.S "Taille mémoire virtuelle théoriquement allouable par le process appelant"
Data.S "Taille mémoire virtuelle dispo pour le process appelant"
EndDataSection