English 中文(简体)
向DLL的切入点传递信息
原标题:Passing messages to a DLL s entry point

我有一个DLL,在入境点,即入境点删除某些代码。

procedure MainDLL(Reason: Integer);
begin
  { ... Code here ... }
end;

begin
  DLLProc := @MainDLL;
end.

现在,我想从外部申请中将一些价值观带给LL的切入点。 我试图在LLL内部建立一个隐蔽的窗口,例如:

const
  WM_JAJCO = WM_USER + 1024;

type
  TWnd = class(TObject)
    class procedure DLLWndProc(var Msg: TMessage);
  end;

{ ... }

class procedure TWnd.DLLWndProc(var Msg: TMessage);
var
  Tmp: DWORD;
begin
  if (Msg.Msg = WM_JAJCO) then
  begin
    PNewHandle := Msg.LParam;
    CreateThread(nil, 0, @Starter, nil, 0, Tmp);

    Msg.Result := 0;
  end else
    Msg.Result := DefWindowProc(MyHnd, Msg.Msg, Msg.WParam, Msg.LParam);
end;

// in the entry point
MyHnd := AllocateHWND(TWnd.DLLWndProc);

然后,在我开始申请电话时,我使用:

SendMessage(FindWindow( TPUtilWindow , nil), WM_USER + 1024, 0, wi.WndHandle);
Application.ProcessMessages();

但是,LLL公司内部创建的窗口似乎没有得到这一信息。 你们是否知道为什么?

If that s a bad method and you have a different solution, please let me know.

最佳回答

第一,确保注入的DL真正能够创造你的窗口。 WinSight或Spy++应当帮助你。 一旦知道窗户确实存在,那么FindWindow就能够找到你的窗户,而不是一个同一类的窗口。 红十字与红新月联会甚至利用Delphi IDE本身也使用这一类别的名称建立了窗口。

问题回答

你们不要为此使用DLLMain。 只是出口你自己的功能,并以人工称呼。

这种做法是相当.的。 在DllMain的职能中,你应尽量少做。 坦率的解决办法是建立专门的职能,以开展初步工作。 安排东道方在发出任何其它信息之前,指定初始职能。

贵版本失败的最可能原因是,有许多窗户,有这个类别的名称。 AllocHwnd创建的每一个窗口都有这一类别名称。 FindWindow可能只是错了。


另一方面,你在发表评论时提到,这部法律被注入! 在这种情况下,你可以通过使用独一无二的类别名称或给窗户以独一无二的称号,使你能够找到自己的方法。

Finally the call to ProcessMessages looks to be gratuitous.





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签