momento de escribir este código para obtener nombre de archivo para guardar mi archivo:cómo guardar el archivo con GetSaveFileName en win32?
#include "stdafx.h"
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = (LPCWSTR)L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = (LPWSTR)szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = (LPCWSTR)L"txt";
GetSaveFileName(&ofn);
printf("the path is : %s\n", ofn.lpstrFile);
getchar();
return 0;
}
Pero la salida es:
the path is : H
por qué? Estoy haciendo algo mal ?
Estoy usando Visual Studio 2008 en Windows 7.
+1 para un ejemplo completo y una pregunta bien formulada. –