当前位置: 首页>>代码示例>>C++>>正文


C++ CFile::Printf方法代码示例

本文整理汇总了C++中CFile::Printf方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::Printf方法的具体用法?C++ CFile::Printf怎么用?C++ CFile::Printf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFile的用法示例。


在下文中一共展示了CFile::Printf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: COMMAND_Modules

void COMMAND_Modules( const char *szCmdLine )
{
    // Get the base address of the requested module
    // Take a snapshot of all modules in the specified process. 
    HANDLE hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, GetCurrentProcessId() );

    if ( hModuleSnap == INVALID_HANDLE_VALUE )
        return;

    // Set the size of the structure before using it. 
    MODULEENTRY32 ModuleEntry; 
    ModuleEntry.dwSize = sizeof(MODULEENTRY32); 

    // Retrieve information about the first module, 
    // and exit if unsuccessful 
    if ( Module32First( hModuleSnap, &ModuleEntry ) ) 
    {
        // Create a file
        CFile *file = modFileRoot->Open( "modules.txt", "w" );

        if ( !file )
            return;

        do
        {
            // Print it
            file->Printf( "** MODULE **\n"
                             "Name: %s\n"
                             "Base: 0x%P\n"
                             "Size: 0x%P\n"
                             "\n",
                             ModuleEntry.szModule,
                             ModuleEntry.modBaseAddr,
                             ModuleEntry.modBaseSize );
        } while ( Module32Next( hModuleSnap, &ModuleEntry ) );

        // Close it
        delete file;
    }

    // Close the snapshot object
    CloseHandle( hModuleSnap ); 
}
开发者ID:qaisjp,项目名称:green-candy,代码行数:43,代码来源:ClientCommands.cpp

示例2: COMMAND_DumpPlayers

void COMMAND_DumpPlayers( const char *szCmdLine )
{
    // Create a file to dump to
    CFile *file = modFileRoot->Open( SString( "dump_%i.txt", GetTickCount32() ), "w" );

    if ( !file )
    {
        g_pCore->GetConsole()->Print( "dumpplayers: Unable to create file" );
        return;
    }

    // Write time now
    file->Printf( "Comments: %s\n", szCmdLine );
    file->Printf( "Time now: %u\n\n", CClientTime::GetTime() );
    file->Printf( "Objectcount: %u\n", g_pClientGame->GetObjectManager()->Count() );
    file->Printf( "Playercount: %u\n", g_pClientGame->GetPlayerManager()->Count() );
    file->Printf( "Vehiclecount: %u\n\n", g_pClientGame->GetVehicleManager()->Count() );

    file->Printf( "Used building pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( BUILDING_POOL ) );
    file->Printf( "Used ped pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( PED_POOL ) );
    file->Printf( "Used object pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( OBJECT_POOL ) );
    file->Printf( "Used dummy pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( DUMMY_POOL ) );
    file->Printf( "Used vehicle pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( VEHICLE_POOL ) );
    file->Printf( "Used col model pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( COL_MODEL_POOL ) );
    file->Printf( "Used task pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( TASK_POOL ) );
    file->Printf( "Used event pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( EVENT_POOL ) );
    file->Printf( "Used task alloc pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( TASK_ALLOCATOR_POOL ) );
    file->Printf( "Used ped intelli pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( PED_INTELLIGENCE_POOL ) );
    file->Printf( "Used ped attractor pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( PED_ATTRACTOR_POOL ) );
    file->Printf( "Used entry info node pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( ENTRY_INFO_NODE_POOL ) );
    file->Printf( "Used node route pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( NODE_ROUTE_POOL ) );
    file->Printf( "Used patrol route pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( PATROL_ROUTE_POOL ) );
    file->Printf( "Used point route pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( POINT_ROUTE_POOL ) );
    file->Printf( "Used point double link pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( POINTER_DOUBLE_LINK_POOL ) );
    file->Printf( "Used point single link pool: %u\n\n\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( POINTER_SINGLE_LINK_POOL ) );

    // Loop through all players
    vector <CClientPlayer*> ::const_iterator iter = g_pClientGame->GetPlayerManager()->IterBegin();
    for ( ; iter != g_pClientGame->GetPlayerManager()->IterEnd(); iter++ )
    {
        // Write the player dump
        DumpPlayer( *iter, file );
    }

    // End of the dump. Close it
    delete file;

    g_pCore->GetConsole()->Print( "dumpplayers: Dumping successfull" );
}
开发者ID:qaisjp,项目名称:green-candy,代码行数:49,代码来源:ClientCommands.cpp


注:本文中的CFile::Printf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。