Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 9 of 9 total |
Pass a Dbisam Dataset as parameter in function call in DLL |
Tue, Apr 12 2011 6:48 AM | Permanent Link |
Petter Topp | Hi.
I would like to pass a Dbisam Dataset as parameter in function call in DLL. I have already set this up with a DLL that is dynamically loaded and unloaded. However I get an AV when closing my application, and in some way it seems to have a relation to handeling of the dataset that was passed with the function. I can do iterations of the datasets, but not gather data from the datasets (FieldByName). Is using datasets passed as parameters a wise approach? Petter Topp Dbisam4 |
Tue, Apr 12 2011 7:31 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Petter
Its a long time since I used DLLs so I may be wrong but my memory is that the DLL and the main process for the application don't share the same memory space. What I remember doing was having the datamodule in the DLL and passing string parameters across to identify the table and record I wanted. If you want to share access to tables etc you have to use packages not DLLs. Roy Lambert [Team Elevate] |
Tue, Apr 12 2011 7:53 AM | Permanent Link |
Petter Topp | Hi Roy.
As you may have understood - it's simply a very convenient way to go... I will have a look at using a dynamic array to pass along key values of data to be worked on, or simply sharing a table for this purpose... Petter "Roy Lambert" skrev i nyhetsmeldingen: CD1E98E0-CACA-4BB6-A35A-062E31EA52EC@news.elevatesoft.com ... Petter Its a long time since I used DLLs so I may be wrong but my memory is that the DLL and the main process for the application don't share the same memory space. What I remember doing was having the datamodule in the DLL and passing string parameters across to identify the table and record I wanted. If you want to share access to tables etc you have to use packages not DLLs. Roy Lambert [Team Elevate] |
Tue, Apr 12 2011 11:35 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Petter
If its something you're going to do much I'd investigate packages. The other question to ask yourself is "why use a DLL?" Way back it made sense because of memory restrictions now I just don't bother and have some monstrous .exes (up to 35Mb whilst in development with debug code). I just had a quick browse on the web and found http://wwv.comanswer.com/question/delphi-dll-form-communication (this one surprised me because it says the dll and application share the same memory space - my memory must be wrong) http://www.delphipages.com/articles/delphi_memory_monitor-9225.html (this one suggests memory mapped files as a good way to communicate) There are also some good threads on the CodeGear ngs eg: https://forums.embarcadero.com/thread.jspa?messageID=216034&tstart=0#216034 Roy Lambert [Team Elevate] |
Tue, Apr 12 2011 4:57 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Petter,
<< I would like to pass a Dbisam Dataset as parameter in function call in DLL. >> Unfortunately, you cannot do so. As Roy indicated, you can use packages to do so, but not DLLs. The reason for this restriction is that the .exe and ..dll have different virtual method tables for classes, and so they cannot understand each other's object layouts. With packages, the virtual method tables are all located in one place. This is the reason for the rule that once you use packages, you cannot have the same code in a package and compiled into the .exe. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Apr 12 2011 4:58 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< (this one surprised me because it says the dll and application share the same memory space - my memory must be wrong) >> They share the same memory space (and with Delphi can even share the same memory manager), but they can't understand each other's classes, so they don't know how to deal with an object instance from the other. This is why simple types work fine as parameters to a DLL, but object instances do not. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Apr 13 2011 2:43 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
>They share the same memory space (and with Delphi can even share the same >memory manager), but they can't understand each other's classes, so they >don't know how to deal with an object instance from the other. This is why >simple types work fine as parameters to a DLL, but object instances do not. So why was it you could pass ShortStrings but not strings? Roy Lambert |
Thu, Apr 14 2011 4:20 AM | Permanent Link |
Petter Topp | Hi Guys.
Thanks for very useful information. Based on this info I have decided to go the safe way - adding a datamodule to the DLL and "share" needed information throgh Dbisam. And just for the record - I'm also happy with just deploying large exe applications, but sometimes it's very convenient to just upgrade a module of the app that are more exposed to outside changes. "Petter Topp" skrev i nyhetsmeldingen: E1CEA262-97F5-462A-858F-71CCA358F06F@news.elevatesoft.com ... Hi. I would like to pass a Dbisam Dataset as parameter in function call in DLL. I have already set this up with a DLL that is dynamically loaded and unloaded. However I get an AV when closing my application, and in some way it seems to have a relation to handeling of the dataset that was passed with the function. I can do iterations of the datasets, but not gather data from the datasets (FieldByName). Is using datasets passed as parameters a wise approach? Petter Topp Dbisam4 |
Tue, Apr 19 2011 6:11 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< So why was it you could pass ShortStrings but not strings? >> I think you can pass long strings also, if you use the shared memory manager (FastMM4). The reason that short strings work is that they are not (normally) dynamically-allocated and aren't reference-counted, and therefore don't need to know from whence they came like long strings. When you assign a short string to another short string, you're copying the entire string from one memory location to the other. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Sunday, May 19, 2024 at 08:46 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |