Bonjour,
Comment on fait pour ne plus que GetOpenFileName crash !!!!

Exception à l'intérieur de la fonction GetOpenFileName,
Commdlg buggé ? oui , sachant que comment font les autre appli !

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
#include "stdafx.h"
#include "afx.h"
#include "commdlg.h"
 
 
int GetTrainFilename(char *Filter,char *TrainFilename)
{
	char s[256];
   OPENFILENAME fn;
   ZeroMemory(&fn,sizeof fn);
   register int i;
   s[0]=0;
   // construct file name filter string
 
   // fill in structure fields for Open File dialog box
OPENFILENAME opf;
    opf.hwndOwner = 0;
	opf.hInstance=0;
    opf.lpstrFilter = Filter;
    opf.lpstrCustomFilter = 0;
    opf.nMaxCustFilter = 0L;
    opf.nFilterIndex = 1L;
    //opf.lpstrFile = 0;
    opf.lpstrFile = s;
	opf.lpstrFile[0]='\0';
    opf.nMaxFile = 256;
    opf.lpstrFileTitle = "";
    opf.nMaxFileTitle=50;
	opf.lpstrInitialDir = "c:\\";
    opf.lpstrTitle = "Open File";
    opf.nFileOffset = 0;
    opf.nFileExtension = 0;
    opf.lpstrDefExt = "*.*";
    opf.lpfnHook = NULL;
    opf.lCustData = 0;
    opf.Flags = (OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT) & ~OFN_ALLOWMULTISELECT;
    opf.lStructSize = sizeof(OPENFILENAME);
 
 
  // *DefaultTrainFile = '\0';
   // activate the Open File dialog box
   if (GetOpenFileName(&opf))
   {
      //lstrcpy(TrainFilename,TrainFilename);
	   strcpy(TrainFilename,opf.lpstrFile);
      return 1;
   }
   else
      return -1;
}
 
int _tmain(int argc, _TCHAR* argv[])
{
	char s[256];
	GetTrainFilename("All\0*.*\0\0",s);
	return 0;
}
Merci bcp