1 |
|
5 |
//------------------------------------------------------------
|
2 |
|
|
//------------------------------------------------------------
|
3 |
|
|
// MAGiC
|
4 |
|
|
// Jean Christophe Cuillière et Vincent FRANCOIS
|
5 |
|
|
// Département de Génie Mécanique - UQTR
|
6 |
|
|
//------------------------------------------------------------
|
7 |
|
|
// Le projet MAGIC est un projet de recherche du département
|
8 |
|
|
// de génie mécanique de l'Université du Québec à
|
9 |
|
|
// Trois Rivières
|
10 |
|
|
// Les librairies ne peuvent être utilisées sans l'accord
|
11 |
|
|
// des auteurs (contact : francois@uqtr.ca)
|
12 |
|
|
//------------------------------------------------------------
|
13 |
|
|
//------------------------------------------------------------
|
14 |
|
|
//
|
15 |
|
|
// alicence.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 à 11H26
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h"
|
26 |
|
|
|
27 |
|
|
#include <vcl.h>
|
28 |
|
|
#pragma hdrstop
|
29 |
|
|
#include <stdio.h>
|
30 |
|
|
#include "alicence.h"
|
31 |
|
|
//---------------------------------------------------------------------------
|
32 |
|
|
#pragma package(smart_init)
|
33 |
|
|
#pragma resource "*.dfm"
|
34 |
|
|
TAboutlicence *Aboutlicence;
|
35 |
|
|
//---------------------------------------------------------------------------
|
36 |
|
|
__fastcall TAboutlicence::TAboutlicence(TComponent* Owner)
|
37 |
|
|
: TForm(Owner)
|
38 |
|
|
{
|
39 |
|
|
}
|
40 |
|
|
//---------------------------------------------------------------------------
|
41 |
|
|
void __fastcall TAboutlicence::Button1Click(TObject *Sender)
|
42 |
|
|
{
|
43 |
|
|
Close();
|
44 |
|
|
Timer1->Enabled=false;
|
45 |
|
|
}
|
46 |
|
|
//---------------------------------------------------------------------------
|
47 |
|
|
void __fastcall TAboutlicence::FormCreate(TObject *Sender)
|
48 |
|
|
{
|
49 |
|
|
HKEY clef;
|
50 |
|
|
DWORD type,taille;
|
51 |
|
|
|
52 |
|
|
nbmodule=5;
|
53 |
|
|
StringGrid1->ColCount=3;
|
54 |
|
|
StringGrid1->RowCount=nbmodule+3;
|
55 |
|
|
StringGrid1->Cells[0][0]="Module";
|
56 |
|
|
StringGrid1->Cells[0][1]="VMM";
|
57 |
|
|
StringGrid1->Cells[0][2]="Mesh";
|
58 |
|
|
StringGrid1->Cells[0][3]="Carte de taille";
|
59 |
|
|
StringGrid1->Cells[0][4]="Mesh erin";
|
60 |
|
|
StringGrid1->Cells[0][5]="Solveur";
|
61 |
|
|
StringGrid1->Cells[1][0]="Licence Libre";
|
62 |
|
|
StringGrid1->Cells[2][0]="Licence Maximale";
|
63 |
|
|
StringGrid1->Cells[0][nbmodule+2]="Date d'expiration";
|
64 |
|
|
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\UQTR\\VMM\\",0,KEY_EXECUTE,&clef);
|
65 |
|
|
int res=RegQueryValueEx(clef,"Serveur",0,&type,0,&taille);
|
66 |
|
|
if (res!=ERROR_SUCCESS)
|
67 |
|
|
{
|
68 |
|
|
MessageBox(Handle,"Problème d'installation","Erreur", MB_OK);
|
69 |
|
|
TerminateProcess(GetCurrentProcess(),0);
|
70 |
|
|
}
|
71 |
|
|
char name[100];
|
72 |
|
|
RegQueryValueEx(clef,"Serveur",0,&type,name,&taille);
|
73 |
|
|
ClientSocket1->Host=name;
|
74 |
|
|
|
75 |
|
|
}
|
76 |
|
|
//---------------------------------------------------------------------------
|
77 |
|
|
|
78 |
|
|
void __fastcall TAboutlicence::Timer1Timer(TObject *Sender)
|
79 |
|
|
{
|
80 |
|
|
ClientSocket1->Open();
|
81 |
|
|
ClientSocket1->Socket->SendText("1");
|
82 |
|
|
Timer1->Interval=5000;
|
83 |
|
|
}
|
84 |
|
|
//---------------------------------------------------------------------------
|
85 |
|
|
|
86 |
|
|
void __fastcall TAboutlicence::ClientSocket1Read(TObject *Sender,
|
87 |
|
|
TCustomWinSocket *Socket)
|
88 |
|
|
{
|
89 |
|
|
AnsiString rep=Socket->ReceiveText();
|
90 |
|
|
char expir[255];
|
91 |
|
|
char *mess=rep.c_str();
|
92 |
|
|
for (int i=0;i<nbmodule;i++)
|
93 |
|
|
{
|
94 |
|
|
int nb1,nb2;
|
95 |
|
|
sscanf(mess,"%d/%d",&nb1,&nb2);
|
96 |
|
|
StringGrid1->Cells[1][i+1]=nb1;
|
97 |
|
|
StringGrid1->Cells[2][i+1]=nb2;
|
98 |
|
|
mess=strchr(mess,' ')+1;
|
99 |
|
|
}
|
100 |
|
|
StringGrid1->Cells[1][nbmodule+2]=mess;
|
101 |
|
|
ClientSocket1->Close();
|
102 |
|
|
}
|
103 |
|
|
//---------------------------------------------------------------------------
|
104 |
|
|
|
105 |
|
|
void __fastcall TAboutlicence::ClientSocket1Error(TObject *Sender,
|
106 |
|
|
TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
|
107 |
|
|
{
|
108 |
|
|
ErrorCode=0;
|
109 |
|
|
for (int i=0;i<nbmodule;i++)
|
110 |
|
|
{
|
111 |
|
|
StringGrid1->Cells[1][i+1]="N/A";
|
112 |
|
|
StringGrid1->Cells[2][i+1]="N/A";
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
ClientSocket1->Close();
|
116 |
|
|
}
|
117 |
|
|
//---------------------------------------------------------------------------
|
118 |
|
|
|
119 |
|
|
void __fastcall TAboutlicence::FormShow(TObject *Sender)
|
120 |
|
|
{
|
121 |
|
|
Timer1->Interval=100;
|
122 |
|
|
Timer1->Enabled=true;
|
123 |
|
|
|
124 |
|
|
}
|
125 |
|
|
//---------------------------------------------------------------------------
|
126 |
|
|
|