9

There are some program tools such as WinSpy++ which will allow you to hover over the Handle of any Control/Component and return the Class Name of that Handle. So for example, if I dropped a TMemo on a Delphi Form and compiled the Application, if I used WinSpy++ and hovered over the Application (above the Memo), it will reveal the Class Name of the Editor as TMemo.

Now, suppose I dont want anybody using such a program to determine the Components I am using in my Application, how would I prevent Class Names from showing up in a tool, such as WinSpy++?

I ask because I dont want anyone to easily create clones of any Applications I may create and release, if the Class Names of the Components I am using are discovered it would make their task easier because then they know what to use.

Simply put, how can I hide the Class Names of the VCL I use in my Delphi Application from external viewer tools like WinSpy++.

WinSpy++ can be found here: http://www.catch22.net/software/winspy

To add, I know I can custom derive these components to change the Class Names to my own, but their must be an easier way.

  • 2
    +1. It is an interesting question. – Andreas Rejbrand May 11 '11 at 12:45
  • 3
    It's hard to imagine that just knowing the classes used would help much unless you app is nothing more than a bunch of controls thrown on a form. Most useful apps have loads of logic too! – David Heffernan May 11 '11 at 12:58
  • 2
    Seems like a waste of time. Only a very trivial app could be cloned this way, and for such an app, it would be trivial to write from scratch, using a screenshot as a "requirements document". – Chris Thornton May 11 '11 at 14:34
  • 2
    Why are you so sure there "must be an easier way" to accomplish something that has almost *no* practical purpose? – Rob Kennedy May 11 '11 at 14:47
  • Well the easier way I thought maybe put the components in a TPanel or similar container, but this wont work. While it may not be a practical purpose for you, it may be for someone else including me. Why are there programs that obfuscate code and resources in applications? because they try to hide the names of the component classes too. My original question would be useful to keep "prying eyes" from snooping over my Applications. –  May 11 '11 at 15:48
  • 2
    @Craig: The reason for obfuscation is because the source is retrievable or the resource can be saved and used somewhere as it exists in the executable (like an image). You're talking about something different entirely. Knowing your app uses a control called `TWidget` in no way reveals the logic that your app has to populate/draw/whatever with that `TWidget`. I agree with @David, @Chris and @Rob - you're going to an awful lot of work for no apparent reason. MS doesn't hide the class names of the parts of the Word GUI, and knowing those names doesn't allow everyone to produce a Word clone. – Ken White May 11 '11 at 17:59
  • You are probably correct that I am trying to achieve something that doesnt seem that important. Regardless if it is worth while or not, it would of been interesting to know if hiding component class names is possible. I will Accept TOndrej answer as he did provide code. Thanks everyone for your comments. –  May 11 '11 at 19:42

1 Answers1

12

You could override CreateParams and put your own class name into Params.WinClassName. The default behaviour is implemented in TWinControl.CreateParams:

with Params do
  ...
  StrPCopy(WinClassName, ClassName);
Ondrej Kelle
  • 36,941
  • 2
  • 65
  • 128
  • 6
    Whilst this hides the class names from Spy, you can get far more information from the .dfm files that are stored as resources in your executable file. – David Heffernan May 11 '11 at 13:30
  • 1
    Yes this is true, but surely a EXE packer such as ASPack would make reading the resources from the Executable difficult anyway, unless I am mistaken? –  May 11 '11 at 14:31
  • 1
    it would make it marginally harder, but it would still be trivial for a half decent developer – David Heffernan May 11 '11 at 17:32
  • Considering the OP's purpose, I'd modify the code straight into `TWinControl` and return a hash of the `ClassName`. That way all controls automatically get weired windows class names. – Cosmin Prund May 11 '11 at 18:05