| View previous topic :: View next topic |
| Author |
Message |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Thu Aug 28, 2008 9:30 am Post subject: [delphi]global prototype function ? |
|
|
in C, you can declare a sexy function like this:
| Code: | | HWND roflWindow = FindWindow() |
then everyone can use it, how can i do it in delphi ?
i tried with type/const, thanks !!
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Thu Aug 28, 2008 9:33 am Post subject: |
|
|
| You mean variable?
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Thu Aug 28, 2008 9:35 am Post subject: |
|
|
| noz3001 wrote: | | You mean variable? |
not variable, i already know how to do global variables, a function without making it.
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Aug 28, 2008 10:11 am Post subject: |
|
|
| "a function without making it"...?
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Thu Aug 28, 2008 10:14 am Post subject: |
|
|
| Prototype?
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Thu Aug 28, 2008 10:29 am Post subject: |
|
|
| Symbol wrote: | | "a function without making it"...? |
i showed an example, -_-
look, in C you can do it like this:
| Code: | #include <windows.h>
HWND dd = FindWindow(NULL, L"Calc");
void main()
{
if(dd != NULL)
//your code
} |
how can i do it in Delphi ?
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Thu Aug 28, 2008 10:34 am Post subject: |
|
|
| ...LOL
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Aug 28, 2008 10:37 am Post subject: |
|
|
| I don't think you can initialize variables outside the code, you can just initialize them in Form_Create.
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Thu Aug 28, 2008 10:39 am Post subject: |
|
|
| Symbol wrote: | | I don't think you can initialize variables outside the code, you can just initialize them in Form_Create. |
But i disline events ;_;
@Renko: my hair is still sexier ;]
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Thu Aug 28, 2008 10:41 am Post subject: |
|
|
| Symbol wrote: | | I don't think you can initialize variables outside the code, you can just initialize them in Form_Create. | Delphi has initialization and finalization sections.
http://delphi.about.com/od/beginners/l/aa051199.htm
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Thu Aug 28, 2008 10:56 am Post subject: |
|
|
what's the finalization routine for ?
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Thu Aug 28, 2008 12:26 pm Post subject: |
|
|
| Rot1 wrote: |
what's the finalization routine for ? |
| http://delphi.about.com/od/beginners/l/aa051199.htm wrote: | | If your unit needs to perform any cleanup when the application terminates, such as freeing any resources allocated in the initialization part; you can add a finalization section to your unit. The finalization section comes after the initialization section, but before the final end. |
Read before you ask please.
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Thu Aug 28, 2008 12:36 pm Post subject: |
|
|
| HolyBlah wrote: | | Rot1 wrote: |
what's the finalization routine for ? |
| http://delphi.about.com/od/beginners/l/aa051199.htm wrote: | | If your unit needs to perform any cleanup when the application terminates, such as freeing any resources allocated in the initialization part; you can add a finalization section to your unit. The finalization section comes after the initialization section, but before the final end. |
Read before you ask please. |
i usually do finalization OnDestory event -.-"
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Thu Aug 28, 2008 12:51 pm Post subject: |
|
|
| From here its easy. If you need some more help or an example just ask.
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Thu Aug 28, 2008 1:28 pm Post subject: |
|
|
| HolyBlah wrote: | | From here its easy. If you need some more help or an example just ask. |
thanks, i tried using init in my .dll (importing it from unit.pas) and it won't work ! why =/ ?
can i have an example of a .dll initializing a HWND variable ? thanks man !
i tried doing this:
| Code: | var hWindow:HWND;
procedure Initialize;
begin
hWindow:=FindWindow(Target, nil);
end;
begin
Initialize;
end. |
|
|
| Back to top |
|
 |
|