/******************************************************************************
* Programme IHM avec API Win32 emglobant :
* - Deux boutons qui appellent CG-NVNF4.exe avec 2200.ini et 1000.ini les noms et
* leur contenu devant être adapté a votre processeur AMD.
* - Afficher la fréquence du processeur pour savoir si nous sommes
* en overclocking, downclocking, nominal
*
* Ce code est prévu pour fonctionner sous Windows avec CG-NVNF4.exe et les
* deux fichiers CG-NVNF4.exe, 2200.ini et 1000.ini adapté a votre processeur.
*
* ATTENTION: Ce programme ne fonctionne que sur des processeurs compatibles
* Intel Pentium ou supérieur (à cause de l'instruction RDTSC).
*
* CE CODE EST SOUS LICENCE GPL : http://www.fsf.org/licenses/gpl.html
* Ce code vous est fourni en esperant vous être utile, mais SANS AUCUNE GARANTIE;
* même sans la garantie que le programme sera adapté a VOTRE USAGE.
* Lisez la licence pour plus de détails.
*
* Attention CG-NVNF4.exe n'est pas forcément en GPL, ce programme étant juste une IHM
* pour le piloter.
* Historique :
* - 22 septembre 2005 : 2 boutons pour executer CG-NVNF4.exe avec un fichier en paramètre.
* - 27 octobre 2005 : Rajout de la detection de fréquence grace a processeur.cpp
*
* Par beridoxy: http://www.beridoxy.com
*****************************************************************************/
#include <windows.h>
#include <stdio.h>
int LitFrequenceCpu (double* frequence);
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "Clock GUI";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Clock GUI", /* Title Text */
WS_OVERLAPPEDWINDOW , /* default window (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Windows/WindowReference/WindowStyles.asp)*/
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
440, /* The programs width */
145, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND Btn1 = 0;
static HWND Btn2 = 0;
static HWND Btn3 = 0;
switch (message) /* handle the messages */
{
case WM_CREATE:
Btn1 = CreateWindowEx(0,"BUTTON","1000.ini (Underclock : 5FID > 1.1V)",WS_CHILD | WS_VISIBLE | BS_TEXT | BS_CENTER |
BS_PUSHBUTTON | BS_NOTIFY | WS_TABSTOP ,
10, 10, 410 ,25, hwnd,NULL, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
/* Calcul la fréquence pour affichage direct sur le bouton */
double frequence;
if (LitFrequenceCpu(&frequence)) {
char str[1024];
frequence = frequence / 1e6;
sprintf(str,"%.8f MHz",frequence);
Btn2 = CreateWindowEx(0,"BUTTON",str,WS_CHILD | WS_VISIBLE | BS_TEXT | BS_CENTER |
BS_PUSHBUTTON | BS_NOTIFY | WS_TABSTOP ,
10, 45, 410 ,25, hwnd,NULL, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
}
else {
MessageBoxA(hwnd,"Impossible de lire la fréquence du processeur !","Erreur",1);
}
Btn3 = CreateWindowEx(0,"BUTTON","2200.ini (Normal : 1.4V > 11FID)",WS_CHILD | WS_VISIBLE | BS_TEXT | BS_CENTER |
BS_PUSHBUTTON | BS_NOTIFY | WS_TABSTOP ,
10, 75, 410 ,25, hwnd,NULL, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED && (HWND) lParam == Btn1) {
int retour;
retour = system("\"CG-NVNF4.exe -file=1000.ini\"");
DestroyWindow (hwnd);
}
if (HIWORD(wParam) == BN_CLICKED && (HWND) lParam == Btn2) {
double frequence;
if (LitFrequenceCpu(&frequence)) {
char str[1024];
frequence = frequence / 1e6;
sprintf(str,"%.8f MHz",frequence);
MessageBoxA(hwnd,str,"TEST",1);
}
else {
MessageBoxA(hwnd,"Impossible de lire la fréquence du processeur !","Erreur",1);
}
}
if (HIWORD(wParam) == BN_CLICKED && (HWND) lParam == Btn3) {
int retour;
retour = system("\"CG-NVNF4.exe -file=2200.ini\"");
DestroyWindow (hwnd);
}
return 0;
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}