Accueil > > > [VC++] API WIN32 : GESTION DE LA RAM EN PROGRESS BAR V 1.1
[VC++] API WIN32 : GESTION DE LA RAM EN PROGRESS BAR V 1.1
Information sur la source
Description
Le code a pour but de vous montrer grace a une progress bar, l'utilisation de votre Ram ! C'est la Version 1.0, car la version avec Texte nessecite une conversion DWLONG -> LPCSTR ! Zone verte : Entre 0 et 41 % Orange Entre 41 et 81 ROUGE + 81 voila plz, ne mettez pas de mauvaise sans expliquer pourquoi dans les commentaires
Source
- #define _WIN32_WINNT 0x0501
- #include <windows.h>
- #include <commctrl.h>
- #pragma comment(lib,"comctl32.lib")
-
- HWND hmain;
- HWND hprg;
- HWND csur;
- HWND soit;
- HWND pcent;
- HWND libre;
-
- char szappname[] = "Rameur";
-
- void __stdcall OnTimerRam()
- {
- MEMORYSTATUSEX mstt;
- DWORD mem;
- long color;
- mstt.dwLength = sizeof(MEMORYSTATUSEX);
- GlobalMemoryStatusEx(&mstt);
- mem = mstt.dwMemoryLoad;
- if(mem < 41) color = RGB(23, 219, 38);
- else if(mem > 81) color = RGB(255, 66, 66);
- else color = RGB(255, 127, 0);
- SendMessage(hprg, PBM_SETBARCOLOR, 0, color);
- SendMessage(hprg, PBM_SETPOS, (WPARAM) mem, 0);
- char buf[12];
- char buf1[12];
- ultoa(mem, buf, 10);
- ultoa(mstt.ullAvailPhys,buf1,10);
- SetWindowText(csur,buf);
- SetWindowText(soit,"% soit ");
- SetWindowText(pcent,buf1);
- SetWindowText(libre,"Oc Libre");
- }
-
- LRESULT CALLBACK AppWndProc(HWND hwnd, UINT mssg, WPARAM wParam, LPARAM lParam)
- {
- switch(mssg) {
- case WM_TIMER:
- OnTimerRam();
- return 0;
- case WM_CREATE:
- hprg = CreateWindowEx(CS_DBLCLKS, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 30, 20, 218, 30, hwnd, 0, 0, 0);
- csur = CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,30,60,200,30,hwnd,0,0,0);
- soit = CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,50,60,200,90,hwnd,0,0,0);
- pcent =CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,95,60,300,90,hwnd,0,0,0);
- libre =CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,175,60,300,90,hwnd,0,0,0);
- SetTimer(hwnd,1,500,NULL);
- SendMessage(hprg, PBM_SETRANGE, 0, MAKELPARAM(0,100));
- return 0;
- case WM_DESTROY:
- KillTimer(hwnd, 1);
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProc(hwnd, mssg, wParam, lParam);
- }
-
- DWORD __stdcall InitInstance(HINSTANCE hinst)
- {
- WNDCLASSEX wndcls;
- INITCOMMONCONTROLSEX iccex;
- iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
- iccex.dwICC = ICC_PROGRESS_CLASS;
- if(!InitCommonControlsEx(&iccex)) return 0;
- memset(&wndcls, 0, sizeof(WNDCLASSEX));
- wndcls.cbSize = sizeof(WNDCLASSEX);
- wndcls.lpfnWndProc = AppWndProc;
- wndcls.style = CS_HREDRAW | CS_VREDRAW;
- wndcls.hInstance = hinst;
- wndcls.lpszClassName = szappname;
- wndcls.hbrBackground = CreateSolidBrush(RGB(236,233,216));
- wndcls.hCursor = LoadCursor(0, IDC_ARROW);
- if(!RegisterClassEx(&wndcls)) return 0;
- hmain = CreateWindowEx(WS_EX_TOPMOST, szappname, szappname, WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, 280, 125, 0, 0, hinst, 0);
- return (hmain != 0);
- }
-
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE x, PSTR y, int z)
- {
- MSG msg;
- if(!InitInstance(hInstance)) return 0;
- ShowWindow(hmain, SW_NORMAL);
- while(GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <commctrl.h>
#pragma comment(lib,"comctl32.lib")
HWND hmain;
HWND hprg;
HWND csur;
HWND soit;
HWND pcent;
HWND libre;
char szappname[] = "Rameur";
void __stdcall OnTimerRam()
{
MEMORYSTATUSEX mstt;
DWORD mem;
long color;
mstt.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&mstt);
mem = mstt.dwMemoryLoad;
if(mem < 41) color = RGB(23, 219, 38);
else if(mem > 81) color = RGB(255, 66, 66);
else color = RGB(255, 127, 0);
SendMessage(hprg, PBM_SETBARCOLOR, 0, color);
SendMessage(hprg, PBM_SETPOS, (WPARAM) mem, 0);
char buf[12];
char buf1[12];
ultoa(mem, buf, 10);
ultoa(mstt.ullAvailPhys,buf1,10);
SetWindowText(csur,buf);
SetWindowText(soit,"% soit ");
SetWindowText(pcent,buf1);
SetWindowText(libre,"Oc Libre");
}
LRESULT CALLBACK AppWndProc(HWND hwnd, UINT mssg, WPARAM wParam, LPARAM lParam)
{
switch(mssg) {
case WM_TIMER:
OnTimerRam();
return 0;
case WM_CREATE:
hprg = CreateWindowEx(CS_DBLCLKS, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 30, 20, 218, 30, hwnd, 0, 0, 0);
csur = CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,30,60,200,30,hwnd,0,0,0);
soit = CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,50,60,200,90,hwnd,0,0,0);
pcent =CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,95,60,300,90,hwnd,0,0,0);
libre =CreateWindowEx(0,"STATIC",NULL,WS_CHILD | WS_VISIBLE,175,60,300,90,hwnd,0,0,0);
SetTimer(hwnd,1,500,NULL);
SendMessage(hprg, PBM_SETRANGE, 0, MAKELPARAM(0,100));
return 0;
case WM_DESTROY:
KillTimer(hwnd, 1);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, mssg, wParam, lParam);
}
DWORD __stdcall InitInstance(HINSTANCE hinst)
{
WNDCLASSEX wndcls;
INITCOMMONCONTROLSEX iccex;
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccex.dwICC = ICC_PROGRESS_CLASS;
if(!InitCommonControlsEx(&iccex)) return 0;
memset(&wndcls, 0, sizeof(WNDCLASSEX));
wndcls.cbSize = sizeof(WNDCLASSEX);
wndcls.lpfnWndProc = AppWndProc;
wndcls.style = CS_HREDRAW | CS_VREDRAW;
wndcls.hInstance = hinst;
wndcls.lpszClassName = szappname;
wndcls.hbrBackground = CreateSolidBrush(RGB(236,233,216));
wndcls.hCursor = LoadCursor(0, IDC_ARROW);
if(!RegisterClassEx(&wndcls)) return 0;
hmain = CreateWindowEx(WS_EX_TOPMOST, szappname, szappname, WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, 280, 125, 0, 0, hinst, 0);
return (hmain != 0);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE x, PSTR y, int z)
{
MSG msg;
if(!InitInstance(hInstance)) return 0;
ShowWindow(hmain, SW_NORMAL);
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
Conclusion
Merci a Brunews qui ma expliquer comment recuperer les notions de memoires RAM Version 1.1 :) Je pense bientot integrer un system de defragmentation de RAM :) voila merci :)
Historique
- 01 février 2006 12:53:25 :
- Code au norm !
- 02 février 2006 20:19:10 :
- EXE en EX_ Dans le Zip !
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
api win32 sdk [ par fabpdg ]
je recherche comment utiliser les fonfions, comme netsessionemun en delphi.Delphi ne reconnaît pas les fonctions api win32 sdk.Comment et quels sont l
equivalent win32 pour linux [ par mbab ]
Bonjour, je debute en c++ et je dois realiser une interface graphique en c++ sous linux. Y a t-il des api tel win32 (pour windows )mais sous linux. Si
Lien DLL 16 / API WIN32 [ par CoreBreaker ]
Bonjour quelqu'un sait-il comment une fonction de l'API Win32 dans une DLL 16bits ?Et de manière générale comment appeler une fonction d'une DLL 32bit
API :: BMP -> RAM !! WARNING !! [ par JackosKing ]
Bon voilà, j'ai fait un projet qui peut affficher des fenetres.au debut les fenetres étaient normale (le progr prenait 800Ko en ram pour 2 fenêtres),
Question API Win32 [ par LordBob ]
Bonjours a tous,j'aimerais avoir quelques info sur les API suivante:EnumWindowsGetWindowcar sinon il faudrai que j'aille voir sur le site de la MSDN m
Existe-t-il un InvokeHelper en Api win32 [ par youpiyoyo ]
comme le titre l'indique j'aurai besoin de sauvegarder un fichier. j'aurais aimer un boite de dlg pour cela.merci d'avance...
l'API win32 sait-elle lire? [ par supergrey ]
Bonjour, je voudrais savoir s'il est possible de récupérer le texte visible dans les page web que je visite sur le net avec un programme.Merci.
2 questions en api win32 [ par youpiyoyo ]
j'aimerai tout d'abord savoir comment mettre un titre sur ma boite de dlg en api win32 sachant ke a border=none dans la gestion des ressources. a mon
Slider bar en API Win32 [ par sebseb42 ]
voila, j'utilise un controle Slider dans une fenetre que je gere en API Win32 (pas de MFC)je voudrais definir sa position initial, pour placer ;e curs
fonctions api win32 [ par mdgtr ]
salutje voudrais obtenir de l'aide apropos d'une source en c++ qui aura comme tache de commander le windows media player a partir d'une fentre mais en
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
RE : WIN APIRE : WIN API par racpp
Cliquez pour lire la suite par racpp WIN APIWIN API par omarino_007
Cliquez pour lire la suite par omarino_007
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|