Solved

Delivering Delphi Component that works Design Time Only ?

Posted on 2010-11-26
9
441 Views
Last Modified: 2012-05-10
Delphi 2010

I am writing a simple component for someone. I want to deliver it to them for testing purposes, but i want it to work in Design Time Only

How do i do this?

Please describe the steps please

thanks
0
Comment
Question by:Looking_4_Answers
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 32

Expert Comment

by:ewangoya
Comment Utility
add this function to your component
uses
  Windows;

function IsInIDE: Boolean;
begin
  Result := (FindWindow('TAppBuilder', nil) > 0) and (DebugHook <> 0);
end;

in the initialization section

initialization
  if not IsInIDE then
  begin
    MessageBox(0, 'Can only run in Delphi', 'Error', MB_OK);
    Application.Terminate; //Halt
  end;
0
 
LVL 25

Expert Comment

by:epasquier
Comment Utility
The first test will tell you that Delphi is loaded, but not that your application is running from Delphi.

That is where the check of DebugHook global variable comes into play, that Delphi sets when integrated debugging is activated and you launch the application from Delphi.

If Delphi integrated debugging is deactivated, then there is no difference between your application launched from Delphi and from explorer while delphi is already loaded.

0
 

Author Comment

by:Looking_4_Answers
Comment Utility
"That is where the check of DebugHook global variable comes into play, that Delphi sets when integrated debugging is activated and you launch the application from Delphi.

If Delphi integrated debugging is deactivated, then there is no difference between your application launched from Delphi and from explorer while delphi is already loaded."

Please Elaborate......maybe with code?
0
 
LVL 25

Expert Comment

by:epasquier
Comment Utility
ewangoya posted a code without explanation, I posted an explanation without code : both work together.

FindWindow('TAppBuilder', nil) >0  => Delphi is loaded somewhere

(DebugHook <> 0)  => that application is running under a debugger.

Both condition at the same time => most certainly that application has been launched from delphi and is being debugged
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:Looking_4_Answers
Comment Utility
Ok, ill try that part of it....but, I do not want to delliver the code for the compoenent.  How do i deliever just the compiled stuff. Package, DCU's, etc
0
 
LVL 24

Expert Comment

by:jimyX
Comment Utility
I have read sometime back that the Register procedure is only called in design mode. You can define a flag in your module and have your register procedure set that flag.  If that flag is clear in your constructor then you are not in design mode.
0
 
LVL 25

Accepted Solution

by:
epasquier earned 500 total points
Comment Utility
design time is another issue. And one that is easily checked with the test :
csDesigning in ComponentState

Looking4Answers : just put all of it in a package, compile it and distribute .BPL and .DCU
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
if you want the absolute certain way :

within your component you could find if you have access to the IDE
basically you can query the IDE with IOTA (Open Tools Api) interfaces from within your component

uses ToolsApi;

function CheckInIde: Boolean;
begin
  Result := BorlandIdeServices <> nil;
end;

I think you need to add DesignEditors to your uses packages of your component
Don't have access to delphi here, i could test on monday

If you are looking for more such info, look for IOTA Delphi in google :)

0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
here is a simple wizard by Allen:
http://edn.embarcadero.com/article/20419

you even get access to the debugger ...
you could even post a message to the debugger window using IOTADebuggerServices;
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now