Salut!!

J'ai un problème ma fonction marche seulement de temps a autre et je n'arrive pas a trouver le problème. (acces violation)

Lorsqu'un mot est taper dans Edit1, si le mot correspond a une liste predefinie. Une application ce lance.

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
 
void __fastcall TForm1::Edit1KeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
 
AnsiString tab[50], tab2[50];
 
 
tab[0]="ant";
tab2[0]="C:\\Program Files\\Ant Movie Catalog\\MovieCatalog.exe";
 
tab[0]="ppt";
tab2[0]="C:\\Program Files\\Microsoft Office\\OFFICE11\\POWERPNT.EXE";
 
tab[0]="ts";
tab2[0]="C:\\Program Files\\Teamspeak2_RC2\\TeamSpeak.exe";
 
     if(Key==VK_RETURN)
     {
        for(int i=0;i<40;i++)
        {
        AnsiString test;
        test=Edit1->Text;
 
        if (test==tab[i])
        {
        char classic[40];
        strcpy (classic, tab2[i].c_str());
        ShellExecute(hwnd,"open",classic,NULL,NULL,SW_SHOWDEFAULT);
        Edit1->Clear();}
        }
     }
}