GetCodeForInitInstance

检索用于 InitInstance 的指定代码。

function GetCodeForInitInstance( 
   nLineStart, 
   nLineEnd  
);

参数

  • nLineStart
    函数起始位置的行号(从零开始编号)。

  • nLineEnd
    函数结束位置的行号(从零开始编号)。

返回值

包含用于初始化向导实例的代码的字符串。

备注

调用该成员函数以检索用于初始化向导实例的适当代码。行号如下:

行号

InitInstance 代码

0

CWinApp::InitInstance();

1

return TRUE;

2

AfxOleInit();

3

// Parse command line for standard shell commands, DDE, file open

4

CCommandLineInfo cmdInfo;

5

ParseCommandLine(cmdInfo);

6

// App was launched with /Embedding or /Automation switch.

7

// Run app as automation server.

8

if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)

9

{

10

\t// Register class factories via CoRegisterClassObject().

11

\tif (FAILED(_AtlModule.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE)))

12

\t\treturn FALSE;

13

\t// Don't show the main window

14

\treturn TRUE;

15

}

16

// App was launched with /Unregserver or /Unregister switch.

17

if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)

18

{

19

\t_AtlModule.UpdateRegistryAppId(FALSE);

20

\t_AtlModule.UnregisterServer(TRUE);

21

\treturn FALSE;

22

}

23

// App was launched with /Register or /Regserver switch.

24

if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppRegister)

25

{

26

\t_AtlModule.UpdateRegistryAppId(TRUE);

27

\t_AtlModule.RegisterServer(TRUE);

28

\treturn FALSE;

29

}

对于返回的每一行,GetCodeForInitInstance 都添加一个前导制表符 (\t) 和一个后缀“CR-LF”(回车 - 换行)字符对 (\r\n)。

示例

// Get the lines numbered 0 through 2 above
GetCodeForInitInstance(0, 2)

// returns the following string
// "\tCWinApp::InitInstance();\r\n\treturn TRUE;\r\n\tAfxOleInit();\r\n"

请参见

任务

创建自定义向导

参考

GetCodeForExitInstance

概念

用公共 JScript 函数自定义 C++ 向导

设计向导

其他资源

用于 C++ 向导的 JScript 函数