Basic example script that prompts a file selection dialog and writes "a\n" into the file
xxxxxxxxxx
int GetSaveFile() {
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "txt";
if(GetSaveFileNameA(&ofn)) {
FILE* file = fopen(szFileName, "w");
if (file == NULL) {
fprintf(stderr, "Unable to open file\n");
return 1;
}
fprintf(file, "a\n");
fclose(file);
} else {
fprintf(stderr, "No file selected\n");
return 1;
}
return 0;
}