Link to home
Start Free TrialLog in
Avatar of doogie
doogie

asked on

Detecting if program running from within Delphi IDE ? Component shareware!

I've created a component that I want to make available as shareware.
I want to be able to detect (As many other shareware components do) if the program using my component, is running from within delphi, or if it is the .exe file that is running on its own, ie not from within delphi?

Ie no registration message displayed while running from within delphi IDE.
When then run in an *.exe, wihtout Delphi IDE, then must not be functional anymore, and display a message saying that this version is unregistered, and needs to be registered first.

How do I test for this from within my component.
My component must be fully functional at 'design time', and when run from within delphi, but not when the compiled *.exe containing the component is run on its own.
Thanks in advance
Adrian
ASKER CERTIFIED SOLUTION
Avatar of ZifNab
ZifNab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Madshi
Madshi

doogie,

I would suggest something like this:

Use "csDesigning in ComponentState" to check in your components create function, if your component is created at designtime or runtime. If it is created at designtime, write a key value to the registry (perhaps a encrypted harddisk serialnumber or something like this). Now if your create function is called at runtime you have to check, whether a valid key value is found in the registry. If not, open an infobox and close the program.

The result of this solution would be that a program that uses your component will run on the computer where it was designed (regardless whether Delphi IDE is currently running or not), but not at all on any other computer.

Regards, Madshi.
Biggest advantage: This solution is totally independent from the delphi version. It will work with every past and future version of delphi.
Avatar of doogie

ASKER

Zifnab ... will this work with Delphi 2,3,4.

I suspect that they might require different solutions.
I need to be able to check for all above versions.

I'll accept your answer if this is so

or

    if csDesigning in ComponentState then ...

should work in all versions.

The other I don't know if they work in higher versions. You've to test this yourself.

Zif.
Avatar of doogie

ASKER

ZifNab
if csDesigning in ComponentState then... works to detect if component specific states are allowed at design time, but as soon as you run the application from within IDE, then if csDesigning in ComponentState returns false, thus not what I need. It should only return false if not running in IDE.

In your one answer the Prefixseg, and MemL are undefined ... can you explain how to use these?

The first answer you gave works, except that for delphi 4 you have to replace .. if WindowExists('TApplication',   'Delphi')    then .. with if WindowExists('TApplication',   'Delphi 4')    then ..
I haven't tested for delphi 2,3 yet, but I hope that it just requires 'Delphi 2' or 'Delphi 3'. .. could place them as OR statements together.


Seems that my comment has been ignored...   :-(
Avatar of doogie

ASKER

No didn't ignore your suggestion ... not entirely in line with what I want. No registry writes!! most programmers don't want components with this behaviour, and quite easy to trick the PC then.
PS If IDE not running, then must not be available!
ok, no problem...
doogie, I'm afraid that PrefixSeg and MemL only exist at D1. So you can't use this method. Sorry.
Avatar of doogie

ASKER

Thanks chaps ... still do some digging till I'm happy with the result. You answered the question, the points are yours.