Packing externals in standalone?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Packing externals in standalone?
I am new to runrev and I am exploring the possibilitys with externals.
Using an external, is it possible to create a single file standalone?
I know that externals are DLL's and must be visible for the OS on calling.
(Must externals exist on startup or on first call? Static/Dynamic binding)
So is there a way to prove at startup if the external exist at a given location and if not, to extract the external to that location to make it work.
Using this approach would make the standalone a 'copy and work' solution.
Using an external, is it possible to create a single file standalone?
I know that externals are DLL's and must be visible for the OS on calling.
(Must externals exist on startup or on first call? Static/Dynamic binding)
So is there a way to prove at startup if the external exist at a given location and if not, to extract the external to that location to make it work.
Using this approach would make the standalone a 'copy and work' solution.
Hans-Peter
Hi Hans-Peter,
I think it is possible to do this to some extent. One possible way is as follows:
(Let the external be called myExternal.dll.)
- Put the contents of the file myExternal.dll into a custom property of your stack. You can do this by doing
- Handle the startup message in your stack script. This is the only place where you can bind an external dll to your stack without restarting Revolution.
- In the startup handler, check if the dll exists, and if not, output it to disk
using something like:
- Then attach the external to your stack using
- You may want to delete myExternal.dll when the stack is closed
Now you should be able to use the external functions and commands contained within myExternal.dll. You can delete the dll from disk when your program is closed.
Unfortunately it is not possible to attach myExternal.dll before the first call to it, because of the way Revolution works, it has to be done on startup.
Hope this helps.
Regards
Oliver
I think it is possible to do this to some extent. One possible way is as follows:
(Let the external be called myExternal.dll.)
- Put the contents of the file myExternal.dll into a custom property of your stack. You can do this by doing
Code: Select all
set the cExternalData of this stack to url ("binfile:myExternal.dll")
- In the startup handler, check if the dll exists, and if not, output it to disk
using something like:
Code: Select all
put the cExternalData of me into url ("binfile:myExternal.dll")
Code: Select all
set the externals of me to "myExternal.dll"
Now you should be able to use the external functions and commands contained within myExternal.dll. You can delete the dll from disk when your program is closed.
Unfortunately it is not possible to attach myExternal.dll before the first call to it, because of the way Revolution works, it has to be done on startup.
Hope this helps.
Regards
Oliver
Oliver Kenyon
Software Developer
Runtime Revolution
Software Developer
Runtime Revolution
Oliver, also thanks for the info.
From other development-enviroments I know that I have to unload a DLL to reset windows reference counter to be able to delete a DLL.
So a DLL in use can't be deleted.
Is it possible with RunRev on ShutDown ?
Where is it done in RunRev?- You may want to delete myExternal.dll when the stack is closed
From other development-enviroments I know that I have to unload a DLL to reset windows reference counter to be able to delete a DLL.
So a DLL in use can't be deleted.
Is it possible with RunRev on ShutDown ?
Hans-Peter
You are referring to an ActiveX DLL. They use reference counting. Plug-ins generally use standard DLL's (unless they do something non-standard and fancy.)HPW wrote:Oliver, also thanks for the info.
Where is it done in RunRev?- You may want to delete myExternal.dll when the stack is closed
From other development-enviroments I know that I have to unload a DLL to reset windows reference counter to be able to delete a DLL.
So a DLL in use can't be deleted.
Is it possible with RunRev on ShutDown ?
The fact is, there are ways to dynamically create and use standard DLL's. I am surprised there's no plug-in that allows you to do that yet. Eventually I'll look into creating plug-ins and see what it'd take to do this.
This is just an addition to Oliver's post.
You can load externals dynamically when they are required. For example using a simple handler:
and a similar unload handler:
The DLL can of course be stored in a custom property and saved out to a file. Be careful with this approach if the DLL is particularly big as the custom property will be loaded into memory.
You can load externals dynamically when they are required. For example using a simple handler:
Code: Select all
on loadExternal pDLL
-- Use "the externals" property of the templateStack to set the DLL
set the externals of the templateStack to pDLL
set the name of the templateStack to (the short name of this stack & "_ExternalWrapper")
create stack
-- library stack this stack to insert the external commands and functions into the message path..
start using stack (the short name of this stack & "_ExternalWrapper")
end loadExternal
Code: Select all
on unloadExternal pDLL
stop using stack (the short name of this stack & "_ExternalWrapper")
delete stack (the short name of this stack & "_ExternalWrapper")
end unloadExternal
Marcus van Houdt
Software Developer at Runtime Revolution
marcus@runrev.com
Software Developer at Runtime Revolution
marcus@runrev.com