I have created a User interface in C++\CLI application which uses a C dll for manipulating exif files. This C dll uses system() funtion opens cmd window and a notepad file for editing and when we close the note pad file the entered data is edited to the exif header comment. Now I have to hide this cmd window I have used "start \b" but this close the cmd window this results in editing of exif header without entering data into the note pad file. The code for this function is as following.
FILE * file;
int a;
char QuotedPath[PATH_MAX+10];
file = fopen(TempFileName, "w");
if (file == NULL)
{
fprintf(stderr, "Can't create file '%s'\n",TempFileName);
ErrFatal("could not create temporary file");
}
fwrite(Comment, CommentSize, 1, file);
fclose(file);
fflush(stdout); // So logs are contiguous.
{
char * Editor;
Editor = getenv("EDITOR");
if (Editor == NULL)
{
#ifdef _WIN32
Editor = "notepad";
#else
Editor = "vi";
#endif
}
if (strlen(Editor) > PATH_MAX) ErrFatal("env too long");
sprintf(QuotedPath, "%s \"%s\"",Editor, TempFileName);
a = system(QuotedPath);
}
if (a != 0)
{
char message[50]= "";
strcpy(message, "Editor failed to launch");
MessageBoxA(hWnd,message,"Error : ",MB_ICONWARNING);
// perror("Editor failed to launch");
exit(-1);
}
if (hFileOpen != NULL)
{
file = fopen(TempFileName, "r");
if (file == NULL)
{
ErrFatal("could not open temp file for read");
}
// Read the file back in.
CommentSize = fread(Comment, 1, 999, file);
fclose(file);
unlink(TempFileName);
return CommentSize;
}