Visual C++ .net (7.0?)
Jeg skal have gemt nogle filer med extension intpd (eks. test.intpd). Jeg
bruger GetSaveFileName dialogboxen og fopen() til at "åbne"/oprette filen.
Så vil jeg gerne vide, hvor jeg skal angive extension. Jeg har prøvet sådan
her:
ZeroMemory(&oofn, sizeof(OPENFILENAME)); // Initialize OPENFILENAME
structure
oofn.lStructSize = sizeof(OPENFILENAME);
oofn.hwndOwner = hWnd;
oofn.lpstrFile = OutputFileNameAndPath; //full path and name of input file
oofn.nMaxFile = sizeof(OutputFileNameAndPath);
oofn.lpstrFilter = "Interpreted files (*.intpd)\0*.intpd\0"; //her troede
jeg så at det skulle angives
oofn.nFilterIndex = 1;
oofn.lpstrFileTitle = NULL;
oofn.nMaxFileTitle = 0;
oofn.lpstrTitle = SaveFileTitle;
oofn.lpstrInitialDir = NULL;
oofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
if (GetSaveFileName(&oofn)) //Display the save file dialog box.
{
OutputFilePtr = fopen(OutputFileNameAndPath, "w"); //opens file for writing
fprintf(OutputFilePtr, "%s %s", &DateTimeBuffer, &FileBuffer); //prints
string to file
fclose(OutputFilePtr); // closes the file
}
else
{
MessageBox(hWnd, "GetSaveFileName dialog could not be opened or user
cancled!", "Error", MB_OK|MB_APPLMODAL);
}
Det virker dog ikke. Filen bliver kun gemt som test uden extension. Kan I
hjælpe mig.
Mvh Jens Rauff
|