Warum schmiert folgende Anwendung ab?
- 
					
					
					
					
 Hallo! 
 Warum schmiert meine Anwendung ab wenn ich folgenden Code aufrufe und dann auf Öffnen klicke?ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.Flags = OFN_FILEMUSTEXIST | OFN_READONLY; ofn.hInstance = hInst; ofn.hwndOwner = hWnd; ofn.lCustData = NULL; ofn.lpfnHook = NULL; ofn.lpTemplateName = NULL; ofn.lpstrCustomFilter = NULL; ofn.lpstrDefExt = "all"; ofn.lpstrFile = ; ofn.lpstrFileTitle = "Öffnen"; ofn.lpstrFilter = "bmp (*.bmp)\0*.BMP\0\0"; ofn.lpstrInitialDir = "C:\\"; ofn.lpstrTitle = "Öffnen"; ofn.lStructSize = sizeof(OPENFILENAME); ofn.nFileExtension = 0; ofn.nFileOffset = 0; ofn.nFilterIndex = 1; ofn.nMaxCustFilter = 0; ofn.nMaxFile = MAX_PATH; ofn.nMaxFileTitle = MAX_PATH; GetOpenFileName(&ofn);
 
- 
					
					
					
					
 Bei ofn.lpstrFilter = "bmp (.bmp)\0.BMP\0\0"; muss glaub ich das letzte \0 weg! 
 
- 
					
					
					
					
 Das Attribut lpstrFile bekommt irgendwie bei dir nichts zugewiesen. 
 So sollte es auf jeden Fall gehen:static char path[MAX_PATH]={""}; OPENFILENAME ofn; memset(&ofn, NULL, sizeof(OPENFILENAME)); ofn.hwndOwner=hwnd; ofn.lStructSize=sizeof(OPENFILENAME); ofn.hInstance=GetModuleHandle(0); ofn.lpstrTitle="Öffnen"; ofn.lpstrFilter="Bitmapps (*.bmp)\0*.bmp\0\0"; ofn.lpstrCustomFilter=NULL; ofn.nMaxCustFilter=NULL; ofn.nFilterIndex=1; ofn.lpstrFile=path; ofn.nMaxFile=MAX_PATH; ofn.lpstrFileTitle=NULL; ofn.nMaxFileTitle=NULL; ofn.lpstrInitialDir=NULL;// aktuelles Verzeichnis ofn.Flags=OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; GetOpenFileName(&ofn);Der Pfad zu der Datei steht dann in der Variablen 'path'. 
 
- 
					
					
					
					
 same problem: static char path[MAX_PATH]={""}; ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.Flags = OFN_FILEMUSTEXIST | OFN_READONLY; ofn.hInstance = hInst; ofn.hwndOwner = hWnd; ofn.lCustData = NULL; ofn.lpfnHook = NULL; ofn.lpTemplateName = NULL; ofn.lpstrCustomFilter = NULL; ofn.lpstrDefExt = "all"; ofn.lpstrFile = path; ofn.lpstrFileTitle = "Öffnen"; ofn.lpstrFilter = "bmp (*.bmp)\0*.BMP\0"; ofn.lpstrInitialDir = "C:\\"; ofn.lpstrTitle = "Öffnen"; ofn.lStructSize = sizeof(OPENFILENAME); ofn.nFileExtension = 0; ofn.nFileOffset = 0; ofn.nFilterIndex = 1; ofn.nMaxCustFilter = 0; ofn.nMaxFile = MAX_PATH; ofn.nMaxFileTitle = MAX_PATH; GetOpenFileName(&ofn);
 
- 
					
					
					
					
 @flenders 
 Muß nicht, kann aber -> ist überflüssig.@Surkevin 
 Deine Initialisierung von lpstrFileTitle und nMaxFileTitle stimmt nicht. Da Du das aber scheinbar nicht brauchst, mach es einfach so:ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0;
 
- 
					
					
					
					
 Jo, da King hats wieder gewusst  
 THX!
 
- 
					
					
					
					
 Du hättest dir auch mal mein Beispiel anschauen können  
 
- 
					
					
					
					
 leude könnt ihr mir mal sagen warum ihr ZeroMemory, memset oder = {0} benutzt und dann trotzdem noch fast alle Member "von Hand" aus nullt? Ich glaub ihr wißt garnicht was ihr da macht. :p 
 
- 
					
					
					
					
 kann ich nur zustimmen. ausserdem zockt man zu weihnachten fette games wie zoo tycoon ( weihnachtsgeschenk von meinem bruder ) und lässt das proggen mal für ein paar stunden sein  adios 
 
- 
					
					
					
					
 lpstrFilter 
 Pointer to a buffer containing pairs of null-terminated filter strings. The last string in the buffer must be terminated by two NULL characters.
 
- 
					
					
					
					
 "" // eins "\0" // zwei, reicht also "\0\0" // drei