Discussion:
Statische und Dynamische DLL und Übergabeparameter
(too old to reply)
Nicolas Bronke
2012-01-26 17:46:13 UTC
Permalink
Ich habe verschiedene Funktionen, die bisher Statisch aufgerufen wurden. Nun
wollte ich die auf dynamischen Aufruf umstellen um Resourcen zu sparen.
Aber irgendwie klappt das nicht so richtig. Die Parameter passen zusammen
und dennoch kommt es zu einer Exception.

Gibt es da Beschränkungen z, B. kein TImage oder so?

Grüsse
Nicolas
Jamie
2012-01-26 23:53:20 UTC
Permalink
Post by Nicolas Bronke
Ich habe verschiedene Funktionen, die bisher Statisch aufgerufen wurden. Nun
wollte ich die auf dynamischen Aufruf umstellen um Resourcen zu sparen.
Aber irgendwie klappt das nicht so richtig. Die Parameter passen zusammen
und dennoch kommt es zu einer Exception.
Gibt es da Beschränkungen z, B. kein TImage oder so?
Grüsse
Nicolas
The translator didn't do a very good job with your post, so I'll attempt
to answer you as best as I understand it.

Var
B:Timage;
Begin
B := Timage.Create(form1); // assign an owner for clean up later.
B.Width := ?
B.Height:= ?
B.Parent := Form1; // This is needed to show it on the form.
etc

// B is now a valid.


when you are done with the Timage.. You can do this :

B.free;

End;

Was this what you were after?


Jamie
Nicolas Bronke
2012-01-27 09:05:29 UTC
Permalink
Post by Jamie
Post by Nicolas Bronke
Ich habe verschiedene Funktionen, die bisher Statisch aufgerufen wurden. Nun
wollte ich die auf dynamischen Aufruf umstellen um Resourcen zu sparen.
Aber irgendwie klappt das nicht so richtig. Die Parameter passen zusammen
und dennoch kommt es zu einer Exception.
Gibt es da Beschränkungen z, B. kein TImage oder so?
The translator didn't do a very good job with your post, so I'll attempt
to answer you as best as I understand it.
Sorry I chosed the wrong newsgroup, I wanted to post in a german newsgroup.

What I wanted to do is that insideDLL setting the Height or witdh or other
parameters. I need it because I include in my application different customer
logos.
The TImage is placed in the application where I do the reading of the file.
I thought if I use TImage as a parameter only a the address is the
parameter.
Regards
Nicolas
Jamie
2012-01-28 00:01:07 UTC
Permalink
Post by Nicolas Bronke
Post by Jamie
Post by Nicolas Bronke
Ich habe verschiedene Funktionen, die bisher Statisch aufgerufen wurden. Nun
wollte ich die auf dynamischen Aufruf umstellen um Resourcen zu sparen.
Aber irgendwie klappt das nicht so richtig. Die Parameter passen zusammen
und dennoch kommt es zu einer Exception.
Gibt es da Beschränkungen z, B. kein TImage oder so?
The translator didn't do a very good job with your post, so I'll
attempt to answer you as best as I understand it.
Sorry I chosed the wrong newsgroup, I wanted to post in a german newsgroup.
What I wanted to do is that insideDLL setting the Height or witdh or
other parameters. I need it because I include in my application
different customer logos.
The TImage is placed in the application where I do the reading of the file.
I thought if I use TImage as a parameter only a the address is the
parameter.
Regards
Nicolas
what you need to do is learn how to use resources..

You can compile your DLL file with a Resource file that you create
containing all the images you need in bmp format as RT_RCDATA or
RT_BITMAP type.

There are many functions you can use to get an image from resource of
a DLL or your main app, you simply need to specify the handle module,
something that you can get with a simple helper function in the DLL.

For example, you have API's like LoadImage, LoadBMP that can load
directly from resource and use the returned handle to directly set a
bitmap image.

Use a Win32 help file and look for the "Resource Functions".

you can create a DLL in Delphi and simply and a basic resource
file that you create which points to the various images on your system
to be linked into the DLL's resource.

Jamie

Jamie
2012-01-27 00:04:58 UTC
Permalink
Post by Nicolas Bronke
Ich habe verschiedene Funktionen, die bisher Statisch aufgerufen wurden. Nun
wollte ich die auf dynamischen Aufruf umstellen um Resourcen zu sparen.
Aber irgendwie klappt das nicht so richtig. Die Parameter passen zusammen
und dennoch kommt es zu einer Exception.
Gibt es da Beschränkungen z, B. kein TImage oder so?
Grüsse
Nicolas
Also:

If you are doing VCL code in A DLL, you can not share it with VCL
code in your app. You need to pass raw data between the apps and not
any pointers to VCL objects.

From the help file of an OLD DELPHI
//
If a DLL exports any procedures or functions that pass long strings as
parameters or function results (whether directly or nested in records or
objects), then the DLL and its client applications (or DLLs) must all
use the ShareMem unit. The same is true if one module (application or
DLL) allocates memory with New or GetMem which is deallocated by a call
to Dispose or FreeMem in another module.
ShareMem is the interface unit for the DELPHIMM.DLL shared memory
manager, which must be deployed along with applications and/or libraries
that use ShareMem. When an application or DLL uses ShareMem, the
application or DLL's memory manager is replaced by the memory manager in
DELPHIMM.DLL, making it possible to share dynamically allocated memory
between multiple modules.

When used by an application or library, the ShareMem unit should be the
first unit listed in an application or library's uses clause.

//
Loading...