![](/img/trans.png)
[英]I'm not getting exception but when using a break point i see exception on the stream how can i solve it?
[英]Why i'm getting exception Unable to find an entry point when using SendMessage?
我正在嘗試向記事本窗口發送一些文本。
在form1的頂部:
const int WM_SETTEXT = 0X000C;
//include FindWindowEx
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
//include SendMessage
[DllImport("user32.dll")]
public static extern int SendMessages(IntPtr hWnd, int uMsg, int wParam, string lParam);
然后在構造函數中:
//getting notepad's process | at least one instance of notepad must be running
Process notepadProccess = Process.GetProcessesByName("notepad")[0];
//getting notepad's textbox handle from the main window's handle
//the textbox is called 'Edit'
IntPtr notepadTextbox = FindWindowEx(notepadProccess.MainWindowHandle, IntPtr.Zero, "Edit", null);
//sending the message to the textbox
SendMessages(notepadTextbox, WM_SETTEXT, 0, "This is the new Text!!!");
唯一的例外是:
SendMessages(notepadTextbox, WM_SETTEXT, 0, "This is the new Text!!!");
exe中發生類型為'System.EntryPointNotFoundException'的未處理異常
附加信息:在DLL“ user32.dll”中找不到名為“ SendMessages”的入口點。
完整的異常消息:
System.EntryPointNotFoundException was unhandled
HResult=-2146233053
Message=Unable to find an entry point named 'SendMessages' in DLL 'user32.dll'.
Source=Grads_Scripts
TypeName=""
StackTrace:
at Grads_Scripts.Form1.SendMessages(IntPtr hWnd, Int32 uMsg, Int32 wParam, String lParam)
at Grads_Scripts.Form1..ctor() in D:\C-Sharp\Form1.cs:line 142
at Grads_Scripts.Program.Main() in D:\C-Sharp\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
由於錯誤試圖告訴您,因此不存在此類功能。
您的意思是SendMessage
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.