tools.cpp

来自「游戏编程很好的东西大家看看啊可以学到很多东西」· C++ 代码 · 共 76 行

CPP
76
字号
// Tools.cpp: implementation of the CTools class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Tools.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTools::CTools()
{

}

CTools::~CTools()
{

}

/*---------------------------------------------------------------------------------
功能:获得文件全路径
说明:
返回:
---------------------------------------------------------------------------------*/
int CTools::GetFullFileName( char*	szFileName )
{
	int		count,i,pos;
	char	path[1024], file_name[1024];

	strcpy( file_name, szFileName );

	GetModuleFileName( NULL, path, 1024 );

	count = strlen( path );

	pos = -1;

	for( i = count - 1; i > 0; i-- )
	{
		if( path[i] == '\\' )
		{
			pos = i;

			break;
		}
	}

	if( pos != -1 )
	{
		path[ pos + 1 ] = 0;

		strcat( path, file_name );

		strcpy( szFileName, path );

		return 0;
	}

	return 1;
}

/*---------------------------------------------------------------------------------
功能:设置文件路径(只需设置一个文件名称就可以了)
说明:
返回:
---------------------------------------------------------------------------------*/
int	CTools::SetIniFileName(char* szFileName )
{
	strcpy( m_file_name, szFileName );

	GetFullFileName( m_file_name );

	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?