Search code examples
c++windowswinapiprocesscreateprocess

CreateProcess vs. CreateFile EXE


[Edited]

  • CreateProcess creates a process (for example, from .exe file)

  • CreateFile can create / open a file. If it opens an .exe file, that execution file will run. In this case, is it equal to CreateProcess?

Are there any differences in this case? I'm new to this, thank you in advance!


Solution

  • Your description of what these functions do is incorrect. They serve completely separate purposes.

    • CreateProcess will run an executable file as a process. It will not create a file.

      Creates a new process and its primary thread. The new process runs in the security context of the calling process.

      Source: MSDN

    • CreateFile will open or create a file. It will not execute that file as a process.

      Creates or opens a file or I/O device. The most commonly used I/O devices are as follows: file, file stream, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, and pipe. The function returns a handle that can be used to access the file or device for various types of I/O depending on the file or device and the flags and attributes specified.

      Source: MSDN