ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/VMM/win32/departwin.cpp
Revision: 5
Committed: Tue Jun 12 20:26:34 2007 UTC (18 years, 2 months ago)
Original Path: magic/app/VMM/VMM/win32/departwin.cpp
File size: 5645 byte(s)
Log Message:

File Contents

# User Rev Content
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     // departwin.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    
30     #include <iostream.h>
31     #include <strstream>
32     #include <string.h>
33     #include <Windows.h>
34     #include <Iphlpapi.h>
35     #include <Assert.h>
36     #include <stdlib.h>
37     #include <stdio.h>
38     #pragma comment(lib, "C:\Program Files\Borland\CBuilder6\Lib\PSDK\iphlpapi.lib")
39     #include "departwin.h"
40     #include "typelic.h"
41     #include "main.h"
42     #include "alicence.h"
43    
44    
45     //---------------------------------------------------------------------------
46     #pragma package(smart_init)
47     #pragma resource "*.dfm"
48     Tdepartwinform *departwinform;
49     //---------------------------------------------------------------------------
50     __fastcall Tdepartwinform::Tdepartwinform(TComponent* Owner)
51     : TForm(Owner)
52     {
53     }
54     //---------------------------------------------------------------------------
55     void __fastcall Tdepartwinform::Timer1Timer(TObject *Sender)
56     {
57     Timer1->Interval=0;
58     HKEY clef;
59     DWORD type,taille;
60     char name[10];
61     int res=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\UQTR\\VMM\\",0,KEY_EXECUTE,&clef);
62     if (res!=ERROR_SUCCESS)
63     {
64     MessageBox(Handle,"Problème d'installation","Erreur", MB_OK);
65     TerminateProcess(GetCurrentProcess(),0);
66     }
67     res=RegQueryValueEx(clef,"Serveur",0,&type,0,&taille);
68     if (res!=ERROR_SUCCESS)
69     {
70     RegCloseKey(clef);
71     Ftypelic->ShowModal();
72     }
73     MainForm->Timer1->Enabled=true;
74     Close();
75     }
76     //---------------------------------------------------------------------------
77     void __fastcall Tdepartwinform::FormClose(TObject *Sender,
78     TCloseAction &Action)
79     {
80     Action=caFree;
81     }
82     //---------------------------------------------------------------------------
83     void __fastcall Tdepartwinform::FormShow(TObject *Sender)
84     {
85     Timer1->Interval=5000;
86     departwinform->Left=(int)(0.5*Screen->Width-0.5*departwinform->Width);
87     departwinform->Top=(int)(0.5*Screen->Height-0.5*departwinform->Height);
88    
89     }
90     //---------------------------------------------------------------------------
91     void __fastcall Tdepartwinform::FormPaint(TObject *Sender)
92     {
93     Canvas->Pen->Color=clBlack;
94     Canvas->Pen->Width=10;
95     Canvas->Rectangle(0,0,ClientWidth,ClientHeight);
96     }
97     //---------------------------------------------------------------------------
98     int __fastcall StringHasher(const char *string,long *hash)
99     {
100     unsigned short kbuffer[513];/* Block 1Kb at a time */
101     unsigned short *kindex;/* Index into 1Kb */
102     unsigned short *kend; /* Pointer to end of buffer */
103     unsigned long d0;
104     unsigned long d3 = 0;
105     unsigned long d4 = 0;
106     unsigned long size; /* File size */
107     int pass; /* pass through file */
108     unsigned int u1,u2,u3,u4,h1,h2,h3;
109    
110     size = (unsigned long)strlen(string);
111     kend = (unsigned short *)string + (size>>1);
112     for (pass = 1; pass <= 2; pass++)
113     {
114     kindex = kend;
115     for (d0 = (size+1) >> 1; d0 > 0; d0--)
116     {
117     if (kindex == kend)
118     {
119     if(pass == 1)
120     {
121     strcpy((char *)kbuffer,string);
122     kbuffer[size+1] = 0;
123     }
124     else
125     {
126     strcpy((char *)kbuffer,string);
127     kbuffer[size+1] = 1;
128     }
129     kindex = kbuffer;
130     }
131    
132     d3 = d3+*(kindex++);
133     d4 = (unsigned short)(d4+(d3>>16));
134     d3 = (unsigned short)d3;
135    
136     if (d4 < (unsigned short)d0)
137     {
138     d4 = d4+65536L-(unsigned short)d0;
139     d3 = (unsigned short)(d3+1);
140     }
141     else
142     d4 = d4-(unsigned short)d0;
143    
144     d4 = d4+d3;
145     d3 = (unsigned short)(d3+(d4>>16));
146     d4 = (unsigned short)d4;
147    
148     d3 <<= 1;
149     d4 = (d4<<1)+(d3>>16);
150     d3 = (unsigned short)d3+(d4>>16);
151     d4 = (unsigned short)d4;
152     }
153     }
154    
155     u1 = (unsigned int)(d4 & 0777);
156     u2 = (unsigned int)((((d4 & 0177400)>>8)|((d4 & 0777)<<8)) & 0777);
157     u3 = (unsigned int)(d3 & 0777);
158     u4 = (unsigned int)((((d3 & 0177400)>>8)|((d3 & 0777)<<8)) & 0777);
159    
160     h3 = u4 + ((u3 & 0x07) << 9);
161     h2 = ((u3 & 0x1F8) >> 3) + ((u2 & 0x3F) << 6);
162     h1 = ((u2 & 0x1C0) >> 6) + (u1 << 3);
163    
164     *hash = ((h3<<24) | (h2<<12) | h1) & 0xFFFFFFFF;
165    
166     return(1);
167     }
168     //---------------------------------------------------------------------------
169    
170    
171    
172     void __fastcall Tdepartwinform::FormCreate(TObject *Sender)
173     {
174     char mess[255];
175     sprintf(mess,"Visual MAGiC Modulaire %s ver %s.%s.%s",VERSION,RSAT,RSTEP,RSLD);
176     Label1->Caption=mess;
177     AnsiString Da=__DATE__;
178     AnsiString Ti=__TIME__;
179    
180     Label4->Caption=Da + " A " + Ti;
181     }
182     //---------------------------------------------------------------------------
183