看板 C_Sharp 關於我們 聯絡資訊
這問題困擾我好久 希望知道的高手能夠指點一下 問題: 原本有一個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://www.ptt.cc/bbs/C_Sharp/M.1505454305.A.D13.html
pzyc79: 我試了 最後都得到Error: Access is denied. 09/17 16:10
godzilla1954: 請問您是用怎樣方法 可以分享一下嗎 09/18 16:16
pzyc79: The console window belongs to the CSRSS process, not 09/18 17:03
pzyc79: the CMD.EXE process. CSRSS is a critical system servic 09/18 17:03
pzyc79: that is protected and cannot be hooked without special 09/18 17:04
pzyc79: debug privileges. 09/18 17:04
pzyc79: 我是用 user32::SetWindowProc 09/18 17:08
hatasum: 如果用console呼叫一個隱藏的winform,那個winform接受wn 11/03 14:01
hatasum: dproc呢? 11/03 14:01