What is the correct way to use ShellExecute() in C to open a .txt

后端 未结 4 1942
时光说笑
时光说笑 2020-12-18 14:26

Alright so i need to open a .txt file that will be created in the same file as the program.

I would like to use ShellExecute(); to do this and i have done a lot of

4条回答
  •  北海茫月
    2020-12-18 14:43

    The ShellExecute function syntax on MSDN:

    HINSTANCE ShellExecute(
      _In_opt_ HWND    hwnd,
      _In_opt_ LPCTSTR lpOperation,
      _In_     LPCTSTR lpFile,
      _In_opt_ LPCTSTR lpParameters,
      _In_opt_ LPCTSTR lpDirectory,
      _In_     INT     nShowCmd
    );
    

    You can try like this. You could open "notepad" with parameter of your text file path ("c:\\debug.txt"):

    ShellExecute(0,"open", "notepad", "c:\\debug.txt", NULL, SW_SHOW);
    

提交回复
热议问题