¿Cuál es la forma correcta de usar ShellExecute () en C para abrir un .txt?
De acuerdo, necesito abrir un archivo .txt que se creará en el mismo archivo que el programa.
Me gustaría usar ShellExecute (); para hacer esto, he investigado mucho y parece que no puedo corregir la sintaxis principalmente porque no sé qué hacer con el parámetro "HWND"
Miréaquí para las respuestas y obtuve toda la información excepto qué poner en HWND
Aquí es cómo necesito el código utilizado:
ShellExecute(0,"open","c:\\debug.txt",NULL,NULL,1);
Gracias por la ayuda, pregunte si no está seguro de lo que estoy hablando. :)
Este es el programa que uso para probar la función:
#include "DAL.h"
//DAL.h added to Testing file to make compiling easier
//Created to test show_debug()
int main(void)
{
int test1,test2,final;
puts("Enter 2 numbers to add (2,2)");
scanf("%d,%d",&test1,&test2);
log_debug(test1);
log_debug(test2);
view_debug();
final= test1+test2;
printf("%d\n",final);
log_debug(final);
return(0);
}
view_debug (); Es la función que incluye ShellExecute.
void view_debug(void)//WIP
//Opens the debug.txt in notepad
{
LoadLibrary( "shell32.dll" );
ShellExecute(0,"open","c:\\debug.txt",NULL,NULL,1);
}
Esto es log_debug ();
int log_debug(int test_variable)
//This function simply tests the programmers desired veriable & displays it for help in keeping track of a veriables value(integer).
//The function has support for upto 1 variable for testing
{
time_t now;
time(&now);
FILE *debug; //Creates file to write debug info
debug=fopen("debug.txt", "a+");
fprintf(debug,"DEBUG %.24s: <%d>\n", ctime(&now),test_variable);
//TODO: Allow more than one variable
fclose(debug);
return(0);
}
El archivo es creado por la función log_debug (); y funciona, pero debe abrirse manualmente porque ShellExecute no funciona.
Fuente completaAquí.