title: What is the correct way to use ShellExecute() in C to open a .txt
body: <p>Alright so i need to open a .txt file that will be created in the same file as the program. </p>
  
  <p>I would like to use ShellExecute(); to do this and i have done a lot of research on it and i just cant seem to get the syntax correct mostly because i dont know what to do with the parameter "HWND"</p>
  
  <p>I looked <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx" rel="nofollow">here</a> for the answers and got all the info except what to put in HWND</p>
  
  <p>Here is how i need the code used:</p>
  
  <pre><code>ShellExecute(0,"open","c:\\debug.txt",NULL,NULL,1);
  </code></pre>
  
  <p>Thanks advance for the help ask if you are unsure what i am talking about! :)</p>
  
  <p>This is the program that i use to test the function:</p>
  
  <pre><code>  #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",&amp;test1,&amp;test2);
  
    log_debug(test1);
    log_debug(test2);
  
    view_debug();
  
    final= test1+test2;
    printf("%d\n",final);
  
    log_debug(final);
  
    return(0);
  }
  </code></pre>
  
  <p>view_debug(); is the function that includes ShellExecute</p>
  
  <pre><code>void view_debug(void)//WIP
  //Opens the debug.txt in notepad
  {
      LoadLibrary( "shell32.dll" );
      ShellExecute(0,"open","c:\\debug.txt",NULL,NULL,1);
  }
  </code></pre>
  
  <p>This is log_debug();</p>
  
  <pre><code>int log_debug(int test_variable)
  //This function simply tests the programmers desired veriable &amp; 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(&amp;now);
  
      FILE *debug; //Creates file to write debug info
  
      debug=fopen("debug.txt", "a+");
      fprintf(debug,"DEBUG %.24s: &lt;%d&gt;\n", ctime(&amp;now),test_variable);
      //TODO: Allow more than one variable
  
      fclose(debug);
  
      return(0);
  }
  </code></pre>
  
  <p>The file is created by the function log_debug(); and it does work but must be opened manually because ShellExecute does not work.</p>
  
  <p>Full Source <a href="https://github.com/Bevilacqua/DAL" rel="nofollow">Here.</a></p>