作者godzilla1954 (阿维)
看板C_Sharp
标题[问题] console模式下 使否有类似WndProc的方法取得message?
时间Fri Sep 15 13:45:02 2017
这问题困扰我好久 希望知道的高手能够指点一下
问题:
原本有一个C#视窗程式 这个程式呼叫别人写的API
[DllImport(@"..\API.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool GetInformation(IntPtr app );
呼叫这个API 他就会把一些资讯用Message回传
并且将一些参数 或是特定资讯纪录在Msg LParam WParam 等等
为了要取得这些资讯 在视窗程式中会去复写WndProc这个方 去取得Message
并且过滤只拿GetInformation所回传的讯息:
protected override void WndProc(ref Message m)
{
if (m.Msg == APIMessage)
{
int wParam = m.WParam.ToInt32();
int lParam = m.LParam.ToInt32();
switch (wParam)
{
case (int)......
break;
....
}
}
base.WndProc(ref m);
}
我的问题是 今天如果我采用console模式去呼叫API
我想请问 在console模式下 使否有类似WndProc 这样的方法
可以去取得呼叫API後所回传的Message呢???
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.96.158.75
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_Sharp/M.1505454305.A.D13.html
1F:→ pzyc79: 我试了 最後都得到Error: Access is denied. 09/17 16:10
2F:→ godzilla1954: 请问您是用怎样方法 可以分享一下吗 09/18 16:16
3F:→ pzyc79: The console window belongs to the CSRSS process, not 09/18 17:03
4F:→ pzyc79: the CMD.EXE process. CSRSS is a critical system servic 09/18 17:03
5F:→ pzyc79: that is protected and cannot be hooked without special 09/18 17:04
6F:→ pzyc79: debug privileges. 09/18 17:04
7F:→ pzyc79: 我是用 user32::SetWindowProc 09/18 17:08
8F:推 hatasum: 如果用console呼叫一个隐藏的winform,那个winform接受wn 11/03 14:01
9F:→ hatasum: dproc呢? 11/03 14:01