Accueil > > > 2.0 GESTION DE LA RAM EN PROGRESS BAR [VC++] API WIN32
2.0 GESTION DE LA RAM EN PROGRESS BAR [VC++] API WIN32
Information sur la source
Description
Voila la version 2.0 qui sans RACPP n'aurait exister.
Merci beaucoup a lui !
Ce petit utiltaire, va vous permettre de gerer votre utilisation de Memoire Ram.
Merci de ne pas mettre de mauvaise note sans expliquer pourquoi.
Version 2.1 Release Grace a BRUNEWS :)
Source
- #define _WIN32_WINNT 0x0500
- #include <windows.h>
- #include <commctrl.h>
- #include "bnIntA.h"
- #include "resource.h"
-
- #pragma comment(lib, "comctl32.lib")
-
- HBRUSH fond;
- HWND progress, text1, text2, text3, text4, text5, text6, text7, text8;
- char szClassName[] = "WindowsApp";
-
- void __stdcall OnTimer()
- {
- MEMORYSTATUSEX statex;
- DWORD n;
- char buf[32], *c;
- statex.dwLength = sizeof (statex);
- GlobalMemoryStatusEx(&statex);
- // Obtenir la taille de la mémoire totale en Mo:
- n = (DWORD) ((statex.ullTotalPhys >> 20) + 1);
- c = bnultoa(n, buf);
- *c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
- SetWindowText(text4, buf);
- // Obtenir la taille de la mémoire disponible en Mo:
- n = (DWORD) ((statex.ullAvailPhys >> 20) + 1);
- c = bnultoa(n, buf);
- *c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
- SetWindowText(text8, buf);
- // Calculer la taille de la mémoire utilisée en Mo:
- n = (DWORD) ((statex.ullTotalPhys - statex.ullAvailPhys) >> 20);
- c = bnultoa(n, buf);
- *c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
- SetWindowText(text6, buf);
- // Obtenir le pourcentage de la mémoire utilisée:
- n = statex.dwMemoryLoad;
- c = bnultoa(n, buf);
- *c = 32; *(c+1) = '%'; *(c+2) = 0;
- SetWindowText(text1, buf);
- SendMessage(progress, PBM_SETPOS, (WPARAM) n, 0);
- if(n < 41) n = RGB(23, 219, 38);
- else if(n < 81 && n >= 41) n = RGB(255, 127, 0);
- else if(n >= 81) n = RGB(255, 66, 66);
- SendMessage(progress, PBM_SETBARCOLOR, 0, (LPARAM) n);
- }
-
- void __stdcall OnCreate(HWND hwnd)
- {
- HGDIOBJ font = GetStockObject(DEFAULT_GUI_FONT);
- progress = CreateWindowEx(CS_DBLCLKS, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH , 30, 115, 200, 50, hwnd, NULL, 0, NULL);
- text1 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_CENTER , 30,95,200,20,hwnd, 0, 0, NULL);
- SendMessage(text1, WM_SETFONT, (WPARAM)font, 0);
- text2 = CreateWindowEx(0,"STATIC","Jean G et RaCPP", WS_VISIBLE|WS_CHILD | SS_CENTER , 30,180,200,20,hwnd, 0, 0, NULL);
- SendMessage(text2, WM_SETFONT, (WPARAM)font, 0);
- text3 = CreateWindowEx(0,"STATIC","Mémoire totale\t\t:", WS_VISIBLE|WS_CHILD , 30,10,150,20,hwnd, 0, 0, NULL);
- SendMessage(text3, WM_SETFONT, (WPARAM)font, 0);
- text4 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,10,50,20,hwnd, 0, 0, NULL);
- SendMessage(text4, WM_SETFONT, (WPARAM)font, 0);
- text5 = CreateWindowEx(0,"STATIC","Mémoire utilisée\t\t:", WS_VISIBLE|WS_CHILD , 30,35,150,20,hwnd, 0, 0, NULL);
- SendMessage(text5, WM_SETFONT, (WPARAM)font, 0);
- text6 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,35,50,20,hwnd, 0, 0, NULL);
- SendMessage(text6, WM_SETFONT, (WPARAM)font, 0);
- text7 = CreateWindowEx(0,"STATIC","Mémoire disponible\t:", WS_VISIBLE|WS_CHILD , 30,60,150,20,hwnd, 0, 0, NULL);
- SendMessage(text7, WM_SETFONT, (WPARAM)font, 0);
- text8 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,60,50,20,hwnd, 0, 0, NULL);
- SendMessage(text8, WM_SETFONT, (WPARAM)font, 0);
- SendMessage(progress,PBM_SETRANGE,0,MAKELPARAM(0,100));
- SendMessage(progress, PBM_SETBKCOLOR, 0, RGB(236,233,216));
- SetTimer(hwnd,1,500,NULL);
- }
-
- LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch(message) {
- case WM_CREATE:
- OnCreate(hwnd);
- OnTimer(); // AFFICHAGE IMMEDIAT
- return 0;
- case WM_CTLCOLORSTATIC:
- SetTextColor((HDC)wParam,RGB(150,0,75));
- SetBkMode((HDC)wParam, TRANSPARENT);
- return (LRESULT)fond;
- case WM_CLOSE:
- KillTimer(hwnd,1);
- DestroyWindow(hwnd);
- return 0;
- case WM_DESTROY:
- PostQuitMessage (0);
- return 0;
- case WM_TIMER:
- OnTimer();
- return 0;
- default:
- return DefWindowProc (hwnd, message, wParam, lParam);
- }
- return 0;
- }
-
- HWND __stdcall InitInstance(HINSTANCE hinst)
- {
- WNDCLASSEX wincl;
- wincl.hInstance = hinst;
- wincl.lpszClassName = szClassName;
- wincl.lpfnWndProc = WindowProcedure;
- wincl.style = CS_HREDRAW | CS_VREDRAW;
- wincl.cbSize = sizeof(WNDCLASSEX);
- wincl.hIcon = LoadIcon(hinst, (LPCTSTR) IDI_APP);
- wincl.hIconSm = LoadIcon(hinst, (LPCTSTR) IDI_APP);
- wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
- wincl.lpszMenuName = NULL;
- wincl.cbClsExtra = 0;
- wincl.cbWndExtra = 0;
- wincl.hbrBackground = fond;
- if(!RegisterClassEx(&wincl)) return 0;
- return CreateWindowEx(WS_EX_TOPMOST, szClassName, "Mémoire RAM",
- WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, 270,240, 0, 0, hinst, 0);
- }
-
- #pragma comment(linker, "/entry:myWinMain")
- __declspec(naked) int __stdcall myWinMain()
- {
- __asm {
- call dword ptr InitCommonControls
- push 0D8E9ECh ; RGB(236, 233, 216)
- call dword ptr CreateSolidBrush
- mov fond, eax
- push 0
- call dword ptr GetModuleHandle
- push eax
- call dword ptr InitInstance
- lea ebp, [esp-28]
- test eax, eax
- je short progEXIT
- mov esp, ebp
- mov esi, GetMessage
- push SW_NORMAL
- push eax
- mov ebx, TranslateMessage
- call dword ptr ShowWindow
- mov edi, DispatchMessage
- getMSG:
- push 0
- push 0
- push 0
- push ebp
- call esi
- test eax, eax
- je short progEXIT
- push ebp
- call ebx
- push ebp
- call edi
- jmp short getMSG
- progEXIT:
- push 0
- call dword ptr ExitProcess
- }
- }
-
- //int WINAPI WinMain(HINSTANCE hinst, HINSTANCE x, LPSTR y, int z)
- //{
- // MSG messages;
- // HWND hwnd;
- // InitCommonControls();
- // fond = CreateSolidBrush(RGB(236,233,216));
- // hwnd = InitInstance(hinst);
- // if(!hwnd) return 0;
- // ShowWindow(hwnd, SW_SHOW);
- // while(GetMessage(&messages, 0, 0, 0)) {
- // TranslateMessage(&messages);
- // DispatchMessage(&messages);
- // }
- // DeleteObject(fond);
- // return 0;
- //}
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <commctrl.h>
#include "bnIntA.h"
#include "resource.h"
#pragma comment(lib, "comctl32.lib")
HBRUSH fond;
HWND progress, text1, text2, text3, text4, text5, text6, text7, text8;
char szClassName[] = "WindowsApp";
void __stdcall OnTimer()
{
MEMORYSTATUSEX statex;
DWORD n;
char buf[32], *c;
statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx(&statex);
// Obtenir la taille de la mémoire totale en Mo:
n = (DWORD) ((statex.ullTotalPhys >> 20) + 1);
c = bnultoa(n, buf);
*c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
SetWindowText(text4, buf);
// Obtenir la taille de la mémoire disponible en Mo:
n = (DWORD) ((statex.ullAvailPhys >> 20) + 1);
c = bnultoa(n, buf);
*c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
SetWindowText(text8, buf);
// Calculer la taille de la mémoire utilisée en Mo:
n = (DWORD) ((statex.ullTotalPhys - statex.ullAvailPhys) >> 20);
c = bnultoa(n, buf);
*c = 32; *(c+1) = 'M'; *(c+2) = 'o'; *(c+3) = 0;
SetWindowText(text6, buf);
// Obtenir le pourcentage de la mémoire utilisée:
n = statex.dwMemoryLoad;
c = bnultoa(n, buf);
*c = 32; *(c+1) = '%'; *(c+2) = 0;
SetWindowText(text1, buf);
SendMessage(progress, PBM_SETPOS, (WPARAM) n, 0);
if(n < 41) n = RGB(23, 219, 38);
else if(n < 81 && n >= 41) n = RGB(255, 127, 0);
else if(n >= 81) n = RGB(255, 66, 66);
SendMessage(progress, PBM_SETBARCOLOR, 0, (LPARAM) n);
}
void __stdcall OnCreate(HWND hwnd)
{
HGDIOBJ font = GetStockObject(DEFAULT_GUI_FONT);
progress = CreateWindowEx(CS_DBLCLKS, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH , 30, 115, 200, 50, hwnd, NULL, 0, NULL);
text1 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_CENTER , 30,95,200,20,hwnd, 0, 0, NULL);
SendMessage(text1, WM_SETFONT, (WPARAM)font, 0);
text2 = CreateWindowEx(0,"STATIC","Jean G et RaCPP", WS_VISIBLE|WS_CHILD | SS_CENTER , 30,180,200,20,hwnd, 0, 0, NULL);
SendMessage(text2, WM_SETFONT, (WPARAM)font, 0);
text3 = CreateWindowEx(0,"STATIC","Mémoire totale\t\t:", WS_VISIBLE|WS_CHILD , 30,10,150,20,hwnd, 0, 0, NULL);
SendMessage(text3, WM_SETFONT, (WPARAM)font, 0);
text4 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,10,50,20,hwnd, 0, 0, NULL);
SendMessage(text4, WM_SETFONT, (WPARAM)font, 0);
text5 = CreateWindowEx(0,"STATIC","Mémoire utilisée\t\t:", WS_VISIBLE|WS_CHILD , 30,35,150,20,hwnd, 0, 0, NULL);
SendMessage(text5, WM_SETFONT, (WPARAM)font, 0);
text6 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,35,50,20,hwnd, 0, 0, NULL);
SendMessage(text6, WM_SETFONT, (WPARAM)font, 0);
text7 = CreateWindowEx(0,"STATIC","Mémoire disponible\t:", WS_VISIBLE|WS_CHILD , 30,60,150,20,hwnd, 0, 0, NULL);
SendMessage(text7, WM_SETFONT, (WPARAM)font, 0);
text8 = CreateWindowEx(0,"STATIC",0, WS_VISIBLE|WS_CHILD | SS_RIGHT , 180,60,50,20,hwnd, 0, 0, NULL);
SendMessage(text8, WM_SETFONT, (WPARAM)font, 0);
SendMessage(progress,PBM_SETRANGE,0,MAKELPARAM(0,100));
SendMessage(progress, PBM_SETBKCOLOR, 0, RGB(236,233,216));
SetTimer(hwnd,1,500,NULL);
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_CREATE:
OnCreate(hwnd);
OnTimer(); // AFFICHAGE IMMEDIAT
return 0;
case WM_CTLCOLORSTATIC:
SetTextColor((HDC)wParam,RGB(150,0,75));
SetBkMode((HDC)wParam, TRANSPARENT);
return (LRESULT)fond;
case WM_CLOSE:
KillTimer(hwnd,1);
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
PostQuitMessage (0);
return 0;
case WM_TIMER:
OnTimer();
return 0;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
HWND __stdcall InitInstance(HINSTANCE hinst)
{
WNDCLASSEX wincl;
wincl.hInstance = hinst;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_HREDRAW | CS_VREDRAW;
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.hIcon = LoadIcon(hinst, (LPCTSTR) IDI_APP);
wincl.hIconSm = LoadIcon(hinst, (LPCTSTR) IDI_APP);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = fond;
if(!RegisterClassEx(&wincl)) return 0;
return CreateWindowEx(WS_EX_TOPMOST, szClassName, "Mémoire RAM",
WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, 270,240, 0, 0, hinst, 0);
}
#pragma comment(linker, "/entry:myWinMain")
__declspec(naked) int __stdcall myWinMain()
{
__asm {
call dword ptr InitCommonControls
push 0D8E9ECh ; RGB(236, 233, 216)
call dword ptr CreateSolidBrush
mov fond, eax
push 0
call dword ptr GetModuleHandle
push eax
call dword ptr InitInstance
lea ebp, [esp-28]
test eax, eax
je short progEXIT
mov esp, ebp
mov esi, GetMessage
push SW_NORMAL
push eax
mov ebx, TranslateMessage
call dword ptr ShowWindow
mov edi, DispatchMessage
getMSG:
push 0
push 0
push 0
push ebp
call esi
test eax, eax
je short progEXIT
push ebp
call ebx
push ebp
call edi
jmp short getMSG
progEXIT:
push 0
call dword ptr ExitProcess
}
}
//int WINAPI WinMain(HINSTANCE hinst, HINSTANCE x, LPSTR y, int z)
//{
// MSG messages;
// HWND hwnd;
// InitCommonControls();
// fond = CreateSolidBrush(RGB(236,233,216));
// hwnd = InitInstance(hinst);
// if(!hwnd) return 0;
// ShowWindow(hwnd, SW_SHOW);
// while(GetMessage(&messages, 0, 0, 0)) {
// TranslateMessage(&messages);
// DispatchMessage(&messages);
// }
// DeleteObject(fond);
// return 0;
//}
Conclusion
sera encore et encore mis a jour prochainement selon vos commantaire !
pour me suggerer quelque amelioration n'oublier pas les Message Prive et mon email : Jean_guis (AT) hotmail.com
Bon coding :)
Historique
- 09 février 2006 10:44:26 :
- Code au Norm, Reduction de l'exe.
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
TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko [FRAMEWORK 4] LES TASKS ET LE THREAD UI[FRAMEWORK 4] LES TASKS ET LE THREAD UI par fathi
Je viens de passer quelques temps au TechDay's et j'ai pu voir pas mal de session intéressante. Par contre une chose m'a un peu étonné lors de certaines de ces sessions qui abordaient les améliorations du framework .NET (donc le 4.5) : en gros, bea...
Cliquez pour lire la suite de l'article par fathi WORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBEWORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBE par JeremyJeanson
Depuis déjà un an, je conseille vivement les utilisateurs de Workflow Foundation 3 à migrer vers la version 4. L'information qui va suivre ne devrait donc pas trop prendre au dépourvu les personnes qui m'ont suivi. Je profite de ce poste, pour faire le re...
Cliquez pour lire la suite de l'article par JeremyJeanson TECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PCTECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PC par ROMELARD Fabrice
Speakers: Thierry Rapatout, Antoine Petit et Xavier Trebbia Cette session entre dans le cadre des RDV Décideurs des TechDays 2012, elle est liée à la consumérisation de l'IT et la mise en place du "DeskTop as a Service" dans de plus en ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
SALUT!SALUT! par khaoulagenie
Cliquez pour lire la suite par khaoulagenie
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|