?? inifile.cs
字號(hào):
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函數(shù)
//*********************************************************************
// 引入"Kernel32.dll"動(dòng)態(tài)聯(lián)接庫,用于讀寫*.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"動(dòng)態(tài)聯(lián)接庫,用于讀寫*.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"動(dòng)態(tài)聯(lián)接庫,用于讀寫*.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"動(dòng)態(tài)聯(lián)接庫,用于讀寫*.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"動(dòng)態(tài)聯(lián)接庫,用于讀寫*.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"動(dòng)態(tài)聯(lián)接庫,用于處理回收站
//*********************************************************************
[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
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -