⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ini.h

📁 退火算法的一个演示程序,含有源代码,通过画面演示退火算法的原理!
💻 H
字号:



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 预处理
#pragma once
#include <Windows.h>

#define INI_Main _TEXT("Main")
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CIni 类
class CIni
{
public:
	// INI 文件名
	TCHAR m_tzFileName[MAX_PATH];

public:
	// 初始化配置文件
	inline CIni()
	{
		GetModuleFileName(NULL, m_tzFileName, MAX_PATH);
		lstrcpy(m_tzFileName + lstrlen(m_tzFileName) - 4, TEXT(".ini"));
	}

	// 初始化配置文件
	inline CIni(PCTSTR ptzFileName)
	{
		lstrcpy(m_tzFileName, ptzFileName);
	}

	// 获取整数
	inline UINT GetInt(PCTSTR ptzKeyName, INT iDefault = 0, PCTSTR ptzSectionName = INI_Main)
	{
		return GetPrivateProfileInt(ptzSectionName, ptzKeyName, iDefault, m_tzFileName);
	}

	// 设置整数
	inline BOOL SetInt(PCTSTR ptzKeyName, INT iValue = 0, PCTSTR ptzSectionName = INI_Main)
	{
		TCHAR tzString[16];

		wsprintf(tzString, TEXT("%d"), iValue);
		return WritePrivateProfileString(ptzSectionName, ptzKeyName, tzString, m_tzFileName);
	}
	
	// 获取实数
	inline UINT GetFloat(PCTSTR ptzKeyName, float fDefault = 0.0, PCTSTR ptzSectionName = INI_Main)
	{
		return GetPrivateProfileInt(ptzSectionName, ptzKeyName, fDefault, m_tzFileName);
		
	}
	
	// 设置实数
	inline bool SetFloat(PCTSTR ptzKeyName, float fValue = 0.0, PCTSTR ptzSectionName = INI_Main)
	{
		TCHAR tzString[64];

		wsprintf(tzString, TEXT("%f"), fValue);
		return WritePrivateProfileString(ptzSectionName, ptzKeyName, tzString, m_tzFileName);
	}

	// 获取字符串
	inline DWORD GetString(PCTSTR ptzKeyName, PTSTR ptzReturnedString,
		DWORD dwSize = MAX_PATH, PCTSTR ptzDefault = NULL, PCTSTR ptzSectionName = INI_Main)
	{
		return GetPrivateProfileString(ptzSectionName, ptzKeyName, ptzDefault, ptzReturnedString,
			dwSize, m_tzFileName);
	}

	// 设置字符串
	inline BOOL SetString(PCTSTR ptzKeyName, PCTSTR ptzString = NULL, PCTSTR ptzSectionName = INI_Main)
	{
		return WritePrivateProfileString(ptzSectionName, ptzKeyName, ptzString, m_tzFileName);
	}

	// 获取结构
	inline BOOL GetStruct(PCTSTR ptzKeyName, PVOID pvStruct, UINT uSize, PCTSTR ptzSectionName = INI_Main)
	{
		return GetPrivateProfileStruct(ptzSectionName, ptzKeyName, pvStruct, uSize, m_tzFileName);
	}

	// 设置结构
	inline BOOL SetStruct(PCTSTR ptzKeyName, PVOID pvStruct, UINT uSize, PCTSTR ptzSectionName = INI_Main)
	{
		return WritePrivateProfileStruct(ptzSectionName, ptzKeyName, pvStruct, uSize, m_tzFileName);
	}

	// 获取节
	inline DWORD GetSection(PTSTR ptzReturnBuffer, DWORD dwSize, PCTSTR ptzSectionName = INI_Main)
	{
		return GetPrivateProfileSection(ptzSectionName, ptzReturnBuffer, dwSize, m_tzFileName);
	}

	// 设置节
	inline DWORD SetSection(PCTSTR ptzString, PCTSTR ptzSectionName = INI_Main)
	{
		return WritePrivateProfileSection(ptzSectionName, ptzString, m_tzFileName);
	}

	// 获取节名
	inline DWORD GetSectionNames(PTSTR ptzReturnBuffer, DWORD dwSize)
	{
		return GetPrivateProfileSectionNames(ptzReturnBuffer, dwSize, m_tzFileName);
	}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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