MarkProfile

更新:2007 年 11 月

MarkProfile 方法在 .vsp 文件中插入分析标记。对包含 MarkProfile 函数的线程进行的分析必须为 ON,才能插入标记。

PROFILE_COMMAND_STATUS PROFILERAPI MarkProfile( long lMarker );

参数

lMarker

要插入的标记。该标记必须大于或等于 0(零)。

属性值/返回值

该函数使用 PROFILE_COMMAND_STATUS 枚举指示成功或失败。返回值可以是下列值之一:

枚举数

说明

MARK_ERROR_MARKER_RESERVED

该参数小于或等于 0。这些值被保留。未记录标记和注释。

MARK_ERROR_MODE_NEVER

调用该函数时,分析模式设置为 NEVER。未记录标记和注释。

MARK_ERROR_MODE_OFF

调用该函数时,分析模式设置为 OFF。未记录标记和注释。

MARK_ERROR_NO_SUPPORT

在此上下文中不支持标记。未记录标记和注释。

MARK_ERROR_OUTOFMEMORY

内存不可用于记录事件。未记录标记和注释。

MARK_TEXTTOOLONG

字符串长度超过最大 256 个字符的限制。注释字符串被截断,并记录了标记和注释。

MARK_OK

返回 MARK_OK 指示成功。

备注

如果正在分析包含 MarkProfile 函数的线程,则每次代码运行时都会在 .vsp 文件中插入标记值。您可以多次调用 MarkProfile。

分析标记具有全局范围。例如,插入到一个线程中的分析标记可用于标记 .vsp 文件中任何线程的数据段的开始或结束。

当通过 Mark 命令或 API 函数(CommentMarkAtProfile、CommentMarkProfile 或 MarkProfile)插入标记和注释时,包含标记分析函数的线程的分析状态必须为开启。

重要说明:

MarkProfile 方法应仅用于检测分析。

.NET Framework 等效项

Microsoft.VisualStudio.Profiler.dll

函数信息

头:在 VSPerf.h 中声明

导入库:VSPerf.lib

示例

下面的代码演示 MarkProfile 函数。

void ExerciseMarkProfile()
{
    // Declare and initialize variables to pass to 
    // MarkProfile.  The values of these parameters 
    // are assigned based on the needs of the code;
    // and for the sake of simplicity in this example, 
    // the variables are assigned arbitrary values.
    int markId = 03;

    // Declare enumeration to hold return value of 
    // call to MarkProfile.
    PROFILE_COMMAND_STATUS markResult;

    // Variables used to print output.
    HRESULT hResult;
    TCHAR tchBuffer[256];

    markResult = MarkProfile(markId);

    // Format and print result.
    LPCTSTR pszFormat = TEXT("%s %d.\0");
    TCHAR* pszTxt = TEXT("MarkProfile returned");
    hResult = StringCchPrintf(tchBuffer, 256, pszFormat, 
        pszTxt, markResult);

#ifdef DEBUG
    OutputDebugString(tchBuffer);
#endif
}

请参见

其他资源

Visual Studio 探查器 API 参考(本机)