Run a simple shell command

前端 未结 3 545
星月不相逢
星月不相逢 2020-12-18 05:00

What is the best WinAPI function to use when you only want to run a simple shell command like hg > test.txt?

3条回答
  •  悲哀的现实
    2020-12-18 05:48

    There are two ways of issuing commands: the Windows Shell way, and the command line way.

    Windows Shell issues commands by executing verbs on files. Verbs are associated with file types in the registry. Examples of common verbs are Open and Print. The WinAPI to use for this is ShellExecute. Windows Shell does not help you pipe the output of a process to a file. You can do it using CreateProcess, but it is a little bit involved.

    The command line way is to use the system function.

提交回复
热议问题