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

📄 inifile.cs

📁 水晶报表使用例子
💻 CS
字号:
using System; 
using System.IO; 
using System.Runtime.InteropServices; 
using System.Text; 

namespace PrintApp
{
	/// <summary>
	/// Summary description for DataCnn.
	/// </summary>
	/// 
	internal class IniFile
	{	
		private string path;
		
		/// <summary>
		/// 传入文件名
		/// </summary>
		/// <param name="iniPath">INI文件名</param>
		public IniFile(string iniPath)
		{
			path = iniPath;
		}

		#region 读写*.ini文件的Api函数
		//*********************************************************************
		//			引入"Kernel32.dll"动态联接库,用于读写*.ini文件
		//*********************************************************************
		[DllImport ("kernel32.dll")] 
		private static extern int GetPrivateProfileInt(
			string lpAppName,	//section name
			string lpKeyName,	//key name
			int nDefault,		//default long
			string lpFileName	//initialization file name
			);
		public int GetPrivateProfileIntA(
			string lpAppName,	//section name
			string lpKeyName,	//key name
			int nDefault,		//default long
			string lpFileName	//initialization file name
			)
		{
			return GetPrivateProfileInt(lpAppName, lpKeyName, nDefault,	 lpFileName	);

		}

		//*********************************************************************
		//			引入"Kernel32.dll"动态联接库,用于读写*.ini文件
		//*********************************************************************
		[DllImport ("kernel32.dll")] 
		private static extern int GetPrivateProfileSection(
			string lpAppName,			//section name
			StringBuilder lpReturnedString,	// destination buffer
			int nSize,					//the size of the max buffer
			string lpFileName			// initialization file name 
			);
		public int GetPrivateProfileSectionA(
			string lpAppName,			//section name
			StringBuilder lpReturnedString,	// destination buffer
			int nSize,					//the size of the max buffer
			string lpFileName			// initialization file name 
			)
		{
			return GetPrivateProfileSection(lpAppName,lpReturnedString,nSize,lpFileName);
		}

		//*********************************************************************
		//			引入"Kernel32.dll"动态联接库,用于读写*.ini文件
		//*********************************************************************
		[DllImport ("kernel32.dll")] 
		private static extern int GetPrivateProfileString(
			string lpAppName, // section name
			string lpKeyName, // key name
			string lpDefault, // default string
			StringBuilder  lpReturnedString, // destination buffer
			int nSize, // size of destination buffer
			string lpFileName // initialization file name 
			);
		public int GetPrivateProfileStringA(
			string lpAppName, // section name
			string lpKeyName, // key name
			string lpDefault, // default string
			StringBuilder lpReturnedString, // destination buffer
			int nSize, // size of destination buffer
			string lpFileName // initialization file name 
			)
		{
			return GetPrivateProfileString(lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize, lpFileName );
		}

		//*********************************************************************
		//			引入"Kernel32.dll"动态联接库,用于读写*.ini文件
		//*********************************************************************
		[DllImport ("kernel32.dll")] 
		private static extern int WritePrivateProfileSection(
			string lpAppName,	// section name
			string lpString,	// destination buffer
			string lpFileName	// initialization file name 
			);
		public int WritePrivateProfileSectionA(
			string lpAppName,	// section name
			string lpString,	// destination buffer
			string lpFileName	// initialization file name 
			)
		{
			return WritePrivateProfileSection(lpAppName,lpString,lpFileName);
		}

		//*********************************************************************
		//			引入"Kernel32.dll"动态联接库,用于读写*.ini文件
		//*********************************************************************
		[DllImport ("kernel32.dll")] 
		private static extern int WritePrivateProfileString(
			string lpAppName,	// section name
			string lpKeyName,	// key name
			string lpString,	// destination buffer
			string lpFileName	// initialization file name 
			);
		public int WritePrivateProfileStringA(
			string lpAppName,	// section name
			string lpKeyName,	// key name
			string lpString,	// destination buffer
			string lpFileName	// initialization file name 
			)
		{
			return WritePrivateProfileString(lpAppName, lpKeyName, lpString, lpFileName);
		}
		#endregion

		#region 回收站处理
		//*********************************************************************
		//			引入"Shell32.dll"动态联接库,用于处理回收站
		//*********************************************************************
		[DllImport ("Shell32.dll")] 
		private static extern int SHEmptyRecycleBin(
			int hwnd,			// Handle 
			string pszRootPath,	// Address of a NULL-terminated string that contains the path of the root drive on which the Recycle Bin is located
			int dwFlags			// Flag
			);
		
		/*
		#define SHERB_NOCONFIRMATION    0x00000001
		#define SHERB_NOPROGRESSUI      0x00000002
		#define SHERB_NOSOUND           0x00000004	
		*/
		
		public int SHEmptyRecycleBinA(
			int hwnd,			// Handle 
			string pszRootPath,	// Address of a NULL-terminated string that contains the path of the root drive on which the Recycle Bin is located
			int dwFlags			// Flag
			)
		{
			return SHEmptyRecycleBin(hwnd,pszRootPath,dwFlags);
		}
		#endregion
	}
}

⌨️ 快捷键说明

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