/ENTRY(入口点符号)/ENTRY (Entry-Point Symbol)

/ENTRY:function

参数Arguments

函数function
一个函数,该函数指定 .exe 文件或 DLL 的用户定义的起始地址。A function that specifies a user-defined starting address for an .exe file or DLL.

备注Remarks

/ENTRY 选项将入口点函数指定为 .exe 文件或 DLL 的起始地址。The /ENTRY option specifies an entry point function as the starting address for an .exe file or DLL.

必须定义函数才能使用 __stdcall 调用约定。The function must be defined to use the __stdcall calling convention. 如果程序为控制台应用程序、windows 应用程序或 DLL,则参数和返回值将依赖于。The parameters and return value depend on if the program is a console application, a windows application or a DLL. 建议使链接器设置入口点,以便正确初始化 C 运行时库,并执行静态对象的 c + + 构造函数。It is recommended that you let the linker set the entry point so that the C run-time library is initialized correctly, and C++ constructors for static objects are executed.

默认情况下,起始地址是 C 运行库中的函数名称。By default, the starting address is a function name from the C run-time library. 链接器将根据程序的属性选择该属性,如下表所示。The linker selects it according to the attributes of the program, as shown in the following table.

函数名称Function name 默认值Default for
mainCRTStartup (或 wmainCRTStartup) mainCRTStartup (or wmainCRTStartup) 使用/SUBSYSTEM:控制台的应用程序;调用 main (或 wmain) An application that uses /SUBSYSTEM:CONSOLE; calls main (or wmain)
WinMainCRTStartup (或 wWinMainCRTStartup) WinMainCRTStartup (or wWinMainCRTStartup) 使用/SUBSYSTEM 的应用程序:WINDOWS;调用 WinMain (或 wWinMain) ,必须将其定义为使用 __stdcallAn application that uses /SUBSYSTEM:WINDOWS; calls WinMain (or wWinMain), which must be defined to use __stdcall
_DllMainCRTStartup_DllMainCRTStartup DLL; DllMain 如果它存在,则调用它,它必须定义为使用 __stdcallA DLL; calls DllMain if it exists, which must be defined to use __stdcall

如果未指定 /DLL/SUBSYSTEM 选项,则链接器将根据是否定义了或来选择子系统和入口点 main WinMainIf the /DLL or /SUBSYSTEM option is not specified, the linker selects a subsystem and entry point depending on whether main or WinMain is defined.

函数 mainWinMainDllMain 是用户定义入口点的三个窗体。The functions main, WinMain, and DllMain are the three forms of the user-defined entry point.

创建托管图像时,指定给/ENTRY 的函数的签名必须是 (LPVOID var1、DWORD var2、LPVOID var3) 。When creating a managed image, the function specified to /ENTRY must have a signature of (LPVOID var1, DWORD var2, LPVOID var3).

有关如何定义自己的 DllMain 入口点的信息,请参阅 dll 和 Visual C++ 运行时库行为For information on how to define your own DllMain entry point, see DLLs and Visual C++ run-time library behavior .

在 Visual Studio 开发环境中设置此链接器选项To set this linker option in the Visual Studio development environment

  1. 打开项目的“属性页” 对话框。Open the project's Property Pages dialog box. 有关详细信息,请参阅在 Visual Studio 中设置 C++ 编译器和生成属性For details, see Set C++ compiler and build properties in Visual Studio.

  2. 单击“链接器”文件夹。Click the Linker folder.

  3. 单击 " 高级 " 属性页。Click the Advanced property page.

  4. 修改 " 入口点 " 属性。Modify the Entry Point property.

以编程方式设置此链接器选项To set this linker option programmatically

请参阅See also

MSVC 链接器参考MSVC linker reference
MSVC 链接器选项MSVC Linker Options