Bonjour a tous,

Voila j'ai un projet avec 4 Unités et 3 forms.

Lorceque je compile j'ai une 40taine d'erreurs qui s'affiche du type:

[Linker Warning] Public symbol '_bAlerte3' defined in both module C:\USERS\BEAULIEU\DESKTOP\SCRUTATIO_RESEAU_V2\U1_MAIN.OBJ and C:\USERS\BEAULIEU\DESKTOP\SCRUTATIO_RESEAU_V2\U2_GESTIONBDD.OBJ

[Linker Warning] Public symbol '_bAlerte3' defined in both module C:\USERS\BEAULIEU\DESKTOP\SCRUTATIO_RESEAU_V2\U1_MAIN.OBJ and C:\USERS\BEAULIEU\DESKTOP\SCRUTATIO_RESEAU_V2\U3_PARAMETREALERTE.OBJ

[Linker Warning] Public symbol '_bAlerte3' defined in both module C:\USERS\BEAULIEU\DESKTOP\SCRUTATIO_RESEAU_V2\U1_MAIN.OBJ and C:\USERS\BEAULIEU\DESKTOP\SCRUTATIO_RESEAU_V2\U4_POSTEDETRAVAIL.OBJ

...

je joint U1 et U3

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
 
//-- U1.cpp --//
 
 
#include <stdio.h>
#include <vcl.h>
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
#include <winsock.h>
#include <iphlpapi.h>
#include <icmpapi.h>
#include <ipexport.h>
#include <sstream.h>
#include <vector>
#include <algorithm>
using namespace std;
 
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "ws2_32.lib")
 
#pragma hdrstop
#include "U1_Main.h"
 
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
 
TForm1 *Form1;
AnsiString ansAddip, ansAddIpFin;
HANDLE g_event;
int cpt=0;
AnsiString NomSwitch;
 
string TabPort[256];
string TabString [256];
 
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
 void __fastcall TForm1::FormActivate(TObject *Sender)
{
        Memo1->Lines->Add("Veuillez entrer une plage d'adresse IP !");
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        int ip11,ip12,ip13,ip14;
        int ip21,ip22,ip23,ip24;
        stringstream ssIpa1,ssIpa2,ssIpa3,ssIpa4,ssIpb1,ssIpb2,ssIpb3,ssIpb4,ssAddIP;
        bool bflag = true;
        int j = 0;
 
        bool bAle3 = Form3->CheckBox3->Checked;
        try
        {
                ip11 = Edit1->Text.ToInt();
                ip12 = Edit2->Text.ToInt();
                ip13 = Edit3->Text.ToInt();
                ip21 = Edit5->Text.ToInt();
                ip22 = Edit6->Text.ToInt();
                ip23 = Edit7->Text.ToInt();
                ip24 = Edit8->Text.ToInt();
                ip14 = Edit4->Text.ToInt();
        }
        catch(...)//EConvertError &err)
        {
                Memo1->Lines->Add("Erreur mauvaise rentrée");
                bflag = false;
        }
        ssIpa1 << ip11;
        ssIpa2 << ip12;
        ssIpa3 << ip13;
        ssIpb1 << ip21;
        ssIpb2 << ip22;
        ssIpb3 << ip23;
        ssIpb4 << ip24;
        ProgressBar1->Position = 0;
        if(bflag==true)
        {
                ProgressBar1->Min = ip14;
                ProgressBar1->Max = ip24;
 
                for(int i=ip14;i<=ip24;i++)
                {
                        ssIpa4<<i;
 
                        ssAddIP<<ssIpa1.str()<<"."<<ssIpa2.str()<<"."<<ssIpa3.str()<<"."<<ssIpa4.str();
 
                        ansAddIpFin = AnsiString(ssIpa4.str().c_str());
                        ansAddip= AnsiString(ssAddIP.str().c_str());
                        if (Ping(ansAddip)==1)
                        {
                            PosteDeTravail Poste(ansAddip,ansAddIpFin,i);
                            j = j+1;;
                        }
                        ssAddIP.str("");
                        ssIpa4.str("");
                        ProgressBar1->Position++;
                }
               Memo1->Lines->Add("Fin de scrutation, nombre de poste trouvé : ");
               Memo1->Lines->Add(j);
               CreatProcess();
               if(bAle3)
               {
                        Form2->Comparaison();
               }
        }
}
//---------------------------------------------------------------------------
 
 int TForm1::Ping(AnsiString ansAdressIP)
{
    HANDLE hIcmpFile;
    char SendData[32] = "Data Buffer";
    DWORD dwRetVal = 0 ;
    LPVOID ReplyBuffer = NULL;
    DWORD ReplySize = 0;
    unsigned long ipadresse;
 
    ipadresse = inet_addr(ansAdressIP.c_str());
    hIcmpFile = IcmpCreateFile();
    if (hIcmpFile == INVALID_HANDLE_VALUE)
    {
       Form1->Memo1->Lines->Add("Impossible d'ouvrir le HANDLE");
    }
 
    ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
    ReplyBuffer = (VOID*) malloc(ReplySize);
    if (ReplyBuffer == NULL)
    {
       Form1->Memo1->Lines->Add("Impossible d'allouer la mémoire");
    }
 
    dwRetVal = IcmpSendEcho(hIcmpFile,ipadresse,SendData,sizeof(SendData),NULL,ReplyBuffer,ReplySize,1);
    if (dwRetVal != 0)
    {
        PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
        struct in_addr ReplyAddr;
        ReplyAddr.S_un.S_addr = pEchoReply->Address;
        return 1;
    }
    else return 0;
}
 
void __fastcall TForm1::Button2Click(TObject *Sender)
{
        Form2->ShowModal();
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::Button3Click(TObject *Sender)
{
         Form3->ShowModal();                
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
        Form2->Table1->Active = false;
        Form2->Table1->DatabaseName = "Ms Access Database";
        Form2->Table1->TableName = "PosteTemp";
        Form2->Table1->TableType = ttDefault;
        Form2->Table1->EmptyTable();
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::Button4Click(TObject *Sender)
{
        Form1->Memo1->Clear();        
}
//---------------------------------------------------------------------------
 
void TForm1::CreatProcess()
{
        STARTUPINFO         siStartupInfo;
        PROCESS_INFORMATION piProcessInfo;
 
        memset(&siStartupInfo, 0, sizeof(siStartupInfo));
        memset(&piProcessInfo, 0, sizeof(piProcessInfo));
        siStartupInfo.cb = sizeof(siStartupInfo);
        AnsiString AddIpSwitch;
 
        AnsiString tab[256];
        int q= 0;
        AnsiString ParamProg;
 
        Form2->Table3->Open();
        Form2->Table1->Open();
        Form2->Table3->First();
        Form2->Table1->First();
        Form2->Table3->Edit();
        Form2->Table1->Edit();
 
        for(int i =1;i<=6;i++)
        {
                TVarRec vr = i;
 
                if(Form2->Table3->FindKey(&vr,0))
                {
                        NomSwitch = Form2->Table3->FieldByName("Nom")->AsString;
                        AddIpSwitch =Form2->Table3->FieldByName("Adresse IP")->AsString;
                }
 
                while(!Form2->Table1->Eof)
                {
                        tab[q]= Form2->Table1->FieldByName("Adresse Mac Decimal")->AsString;
                        Form2->Table1->Next();
                        q++;
                }
                ParamProg = "C:\\Users\\Beaulieu\\Desktop\\NumeroPort\\Project2.exe " + AddIpSwitch + " " ;
                for(int f=0;f<Form2->Table1->RecordCount;f++)
                {
                        ParamProg = ParamProg + tab[f].c_str() + " ";
                }
                if(CreateProcess(NULL,ParamProg.c_str(),0,0,FALSE,CREATE_DEFAULT_ERROR_MODE,0,0,&siStartupInfo,&piProcessInfo) == FALSE)
                {
                        // erreur
                }
                else
                {
                        // attente
                        WaitForSingleObject(piProcessInfo.hProcess, INFINITE);
                       // Form1->Memo1->Lines->Add("Attente ... ");
                        ::CloseHandle(piProcessInfo.hThread);
                        ::CloseHandle(piProcessInfo.hProcess);
                }
                 Form2->Table1->Close();
                 // Form2->Table3->Close();
                LireFichier();
        }
}
 
int suitebis()
{
         string Lignefichierbis2;
         int j=0;
 
         ifstream fichierbis("NumeroPortBis.txt", ios::in);
         if(fichierbis)
         {
                getline(fichierbis, Lignefichierbis2);
 
                string::iterator first2 = Lignefichierbis2.begin();
                string::iterator last2;
                do
                {
                        last2 = find(first2, Lignefichierbis2.end(), 'R');
                        first2 = find(first2, Lignefichierbis2.end(),'r');
                        first2 = first2+3;
                        if (last2 != Lignefichierbis2.end())
                        {
                                TabPort[j] = string((const char*)first2,(const char*)last2);
                        }
                        first2 = last2+9; // a ajouter
                        j++;
                }while (last2 != Lignefichierbis2.end());
         }
         fichierbis.close();
         remove("NumeroPortBis.txt");
         return(j);
 
}
void suite()
{
    string Lignefichierbis,Lignefichierbis2;
    int i=0;
 
    ifstream fichierbis("NumeroPortBis.txt", ios::in);
    if(fichierbis)
    {
        getline(fichierbis, Lignefichierbis);
 
        string::iterator first = Lignefichierbis.begin();
        string::iterator last;
        do
        {
                last = find(first, Lignefichierbis.end(), 'I');
                if (last != Lignefichierbis.end())
                {
                        TabString[i] = string((const char*)first,(const char*)last);
 
                      //  Form1->Memo1->Lines->Add(TabString[i].c_str());
                }
                first = last+12; // a ajouter
                i++;
        }while (last != Lignefichierbis.end());
        fichierbis.close();
    }
}
void compare()
{
     cpt=0;
     cpt = suitebis();
     int mycount;
     Form2->Table1->Open();
     Form2->Table1->First();
     string strPort;
     int port ;
     int TestPort;
 
     for(int i =0;i<cpt;i++)
     {
        mycount = (int) count (TabPort, TabPort+cpt-1, TabPort[i]);
        if(mycount==1)
        {
                AnsiString ansiPort = TabPort[i].c_str();
                AnsiString ansiAddMacDec = TabString[i].c_str();
                while(ansiAddMacDec != Form2->Table1->FieldByName("Adresse Mac Decimal")->Value)
                {
 
                        Form2->Table1->Next();
                        if(Form2->Table1->Eof)
                        {break;}
                }
                if(NomSwitch == "Switch local informatique")
                {
                        port = StrToInt(ansiPort.c_str());
 
                        if(port>=1 && port<=6)
                        {
                                TestPort = 1;
                        }
                        if(port>6 && port<=48)
                        {
                                TestPort = 2;
                        }
                        if(port>48 && port<=72)
                        {
                                TestPort = 3;
                        }
 
                        switch(TestPort)
                        {
                                case 1:
                                {
                                        strPort = "A" + port;
                                        break;
                                }
                                case 2:
                                {
                                        port = port-25+1;
                                        ostringstream oss;
                                        oss<<port;
                                        strPort = "B" + oss.str();
                                        break;
                                }
                                case 3:
                                {
                                        port = port-49+1;
                                        ostringstream oss;
                                        oss<<port;
                                        strPort = "C" + oss.str();
                                        break;
                                }
                        }
 
        }
        else
        {
                strPort = ansiPort.c_str();
        }
        Form2->Table1->Edit();
        Form2->Table1->FieldByName("Port")->Value = strPort.c_str();
        Form2->Table1->FieldByName("Nom Switch")->Value = NomSwitch;
        Form2->Table1->Post();
 
        }
 
     }
}
 
void TForm1::LireFichier()
{
        string LigneFichier, ContAddMac, ContNumPort;
        AnsiString caract;
        char *LigneTotal;
        int separation,CptChar;
        char *espace = " ";
        AnsiString RC = "\n";
        AnsiString test="";
 
        ifstream fichier("NumeroPort.txt", ios::in);  // on ouvre le fichier en lecture
 
        if(fichier)  // si l'ouverture a réussi
        {
                getline(fichier, LigneFichier);
                while(LigneFichier == " ")
                {
                        getline(fichier, LigneFichier);
                }
                LigneTotal =  (char*)LigneFichier.c_str();
                CptChar = strlen(LigneFichier.c_str()) ;
 
                ofstream fichierbis("NumeroPortBis.txt", ios::out | ios::trunc);
 
                for( int i=0;i<=CptChar;i++)
                {
                        if(LigneTotal[i] != *espace)
                        {
                           ofstream fichierbis("NumeroPortBis.txt", ios::out | ios::end);
                           caract = LigneTotal[i];
                           test = test + caract;
                           fichierbis<<test.c_str();
                        }
                       if(LigneTotal[i+1] == *espace)
                        {
                                fichierbis << *espace;
                        }
                        fichierbis.close();
                }
                fichier.close();
                remove("NumeroPort.txt"); 
        }
        suite();
        //suitebis();
        compare();
       // system("pause");
}                         
//-------------------------------------------------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
//--u1.h--//
 
#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <DB.hpp>
#include <DBTables.hpp>
#include <ADODB.hpp>
#include <DBGrids.hpp>
#include <Grids.hpp>
#include <ExtCtrls.hpp>
#include <ComCtrls.hpp>
 
#include "U3_ParametreAlerte.h"
#include "U2_GestionBDD.h"
#include "U4_PosteDeTravail.h"
 
 
bool bAlerte1;
bool bAlerte2;
bool bAlerte3;
 
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TEdit *Edit1;
        TLabel *Label2;
        TEdit *Edit2;
        TEdit *Edit3;
        TEdit *Edit4;
        TEdit *Edit5;
        TEdit *Edit6;
        TEdit *Edit7;
        TEdit *Edit8;
        TButton *Button1;
        TMemo *Memo1;
        TButton *Button2;
        TButton *Button3;
        TLabel *Label1;
        TButton *Button4;
        TProgressBar *ProgressBar1;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall FormActivate(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
        void __fastcall Button3Click(TObject *Sender);
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall Button4Click(TObject *Sender);
 
        private:	// User declarations
        public:		// User declarations
        __fastcall TForm1(TComponent* Owner);
        int Ping(AnsiString);
        void CreatProcess();
        void LireFichier();
 
};
//---------------------------------------------------------------------------
 
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
//--U3.h--//
 
//---------------------------------------------------------------------------
 
#ifndef U5_ParametreAlerteH
#define U5_ParametreAlerteH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
 
#include "U1_Main.h"
//#include "U2_GestionBDD.h"
//#include "U4_PosteDeTravail.h"
 
 
 
//---------------------------------------------------------------------------
class TForm3 : public TForm
{
__published:	// IDE-managed Components
        TLabel *Label1;
        TButton *Button1;
        TPanel *Panel1;
        TLabel *Label2;
        TCheckBox *CheckBox3;
        TCheckBox *CheckBox2;
        TPanel *Panel2;
        TLabel *Label3;
        TCheckBox *CheckBox1;
        TEdit *EditEmail;
        TLabel *Label4;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall CheckBox2Click(TObject *Sender);
        void __fastcall CheckBox3Click(TObject *Sender);
        void __fastcall CheckBox1Click(TObject *Sender);
private:	// User declarations
public:		// User declarations
        __fastcall TForm3(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm3 *Form3;
//---------------------------------------------------------------------------
#endif
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
 
//--U3.cpp--//
 
//---------------------------------------------------------------------------
 
#include <vcl.h>
#pragma hdrstop
#include "U3_ParametreAlerte.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
 
AnsiString sMail="";
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TForm3::Button1Click(TObject *Sender)
{
        Form3->Close();
        sMail = EditEmail->Text;
        Form1->Memo1->Lines->Add(sMail);
}
//---------------------------------------------------------------------------
 
void __fastcall TForm3::CheckBox2Click(TObject *Sender)
{
        bAlerte2 = true;
}
//---------------------------------------------------------------------------
 
void __fastcall TForm3::CheckBox3Click(TObject *Sender)
{
       bAlerte3 = true;
}
//---------------------------------------------------------------------------
 
void __fastcall TForm3::CheckBox1Click(TObject *Sender)
{
       bAlerte1 = true;
}
//---------------------------------------------------------------------------