English 中文(简体)
更改 TCreateParams. WinClassName 或如何找到另一个应用程序的窗体控件是否安全?
原标题:Is it safe to change TCreateParams.WinClassName or how to find a form handle of another own application?

我有两个应用程序, 第一个应用程序需要从第二个( 也是我自己的) 找到表格的手柄, 但不同的应用程序( 不是实例, 而是不同的应用程序 ) 。 我见过一些技术, 但我想知道它是否安全, 我想要做什么或者什么是有效的方法。

我正打算使用 FindWindow 函数, 在那里您可以通过类名, 所以如果我将窗体 < code> winClassName 成员中的 < code> 名 < CreateParams 更改为某种独特的值( 例如, 图形用户界面 D), 那么我很容易找到这个窗口, 很有可能是我应用程序中的窗口 。

申请表格需要找到的:

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.WinClassName :=  {1EE65C52-2F4B-4600-AAE2-079C29AD2220} ;
end;

需要从上一个表格中找到表格的另一种申请:

procedure TForm1.Button1Click(Sender: TObject);
var
  FormHandle: HWND;
begin
  FormHandle := FindWindow( {1EE65C52-2F4B-4600-AAE2-079C29AD2220} , nil);
  ShowMessage(IntToStr(FormHandle));
end;

我的问题是:

将 < code> TCreateParams 中的这个成员更改为我想要的或不安全的东西是否安全? 或者您如何从您自己的另一个应用程序( 不是应用程序实例, 而是您自己的另一个应用程序)中寻找窗体的控件?

非常感谢!

最佳回答

是的,这样做是完全安全的。 自然,每个不同的阶级必须有一个独特的名字,但要由你来确保这一点。

问题回答

与其在两个应用程序中使用相同的 TForm1 类名称,不如习惯于将默认类名称更改为更有意义的名称,例如 Tapp1MainForm Tapp2MainForm 。 VCL自动为您指定一个窗体 ClassName TCreateParams.WinClassName 为默认。 在 TWin Control.CreateParams () 中,如果您在设计时更改对象检查员中的窗体 s Name 属性,它将更新 ClasName





相关问题
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 "...