C#记事本程序中,怎么实现查找,替换功能?
1个回答
展开全部
调用系统查找与替换对话框!
using System.Runtime.interopservices;
[DllImport("comdlg32.dll")]
private static extern IntPtr FindText(ref FINDREPLACE lpfn);
[DllImport("comdlg32.dll")]
private static extern IntPtr ReplaceText(ref FINDREPLACE lpfn);
public struct tagFINDREPLACEW {
/// DWORD->unsigned int
public uint lStructSize;
/// HWND->HWND__*
public System.IntPtr hwndOwner;
/// HINSTANCE->HINSTANCE__*
public System.IntPtr hInstance;
/// DWORD->unsigned int
public uint Flags;
/// LPWSTR->WCHAR*
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string lpstrFindWhat;
/// LPWSTR->WCHAR*
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string lpstrReplaceWith;
/// WORD->unsigned short
public ushort wFindWhatLen;
/// WORD->unsigned short
public ushort wReplaceWithLen;
/// LPARAM->LONG_PTR->int
public int lCustData;
/// LPFRHOOKPROC
public LPFRHOOKPROC lpfnHook;
/// LPCWSTR->WCHAR*
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string lpTemplateName;
}
/// Return Type: UINT_PTR->unsigned int
///param0: HWND->HWND__*
///param1: UINT->unsigned int
///param2: WPARAM->UINT_PTR->unsigned int
///param3: LPARAM->LONG_PTR->int
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
public delegate uint LPFRHOOKPROC(System.IntPtr param0, uint param1, System.IntPtr param2, System.IntPtr param3);
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
using System.Runtime.interopservices;
[DllImport("comdlg32.dll")]
private static extern IntPtr FindText(ref FINDREPLACE lpfn);
[DllImport("comdlg32.dll")]
private static extern IntPtr ReplaceText(ref FINDREPLACE lpfn);
public struct tagFINDREPLACEW {
/// DWORD->unsigned int
public uint lStructSize;
/// HWND->HWND__*
public System.IntPtr hwndOwner;
/// HINSTANCE->HINSTANCE__*
public System.IntPtr hInstance;
/// DWORD->unsigned int
public uint Flags;
/// LPWSTR->WCHAR*
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string lpstrFindWhat;
/// LPWSTR->WCHAR*
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string lpstrReplaceWith;
/// WORD->unsigned short
public ushort wFindWhatLen;
/// WORD->unsigned short
public ushort wReplaceWithLen;
/// LPARAM->LONG_PTR->int
public int lCustData;
/// LPFRHOOKPROC
public LPFRHOOKPROC lpfnHook;
/// LPCWSTR->WCHAR*
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string lpTemplateName;
}
/// Return Type: UINT_PTR->unsigned int
///param0: HWND->HWND__*
///param1: UINT->unsigned int
///param2: WPARAM->UINT_PTR->unsigned int
///param3: LPARAM->LONG_PTR->int
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
public delegate uint LPFRHOOKPROC(System.IntPtr param0, uint param1, System.IntPtr param2, System.IntPtr param3);
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询