C#记事本程序中,怎么实现查找,替换功能?

 我来答
727617686
2012-04-12 · TA获得超过712个赞
知道小有建树答主
回答量:560
采纳率:0%
帮助的人:306万
展开全部
调用系统查找与替换对话框!
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)]
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式