AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to dynamically include Dll files with Included scripts

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat
View previous topic :: View next topic  

What do you think after reading this post?
I think it will work great
0%
 0%  [ 0 ]
I think its too complicated
0%
 0%  [ 0 ]
Total Votes : 0

Author Message
Invalid User



Joined: 14 Feb 2005
Posts: 442
Location: Texas, Usa

PostPosted: Sat Mar 11, 2006 2:20 pm    Post subject: How to dynamically include Dll files with Included scripts Reply with quote

Concerning this thread http://www.autohotkey.com/forum/viewtopic.php?t=5016...

I plan to someday add functions that rely on .dll files and with this comes the way a dll file is referenced in an ahk script. If the full path is left out it is assumed to be in A_WorkingDir of the script. Because of this I am going to have two dirs with in the future releases, and the zip folder in the future will be named "#Include.zip". This new "version" of the release will require it to be unzipped in the dir where ahk is installed. This will allow a function to be made to find the dir of all included folder using A_AhkDir. With this function in place, it will allow users to create multiple scripts(in different dirs) to reference these .dll files so that multiple copies of the .dll are not required. So functions that are included in the download will use this fucntion to find the Dlls dir. The result will be:

A downloadable zip file that unzips and create some dirs like
Code:
#Include\Dll\CtrlSupport.dll
#Include\Functions\CtrlSupport\TreeCtrl.ahk
#Include\Functions\List\ListFuncs.ahk


A fuction that may return something like this:
Code:
A_IncludeDllDir = %A_AhkDir%\#Include\Dll

For the Dlls and
Code:
A_IncludeDir = %A_AhkDir%\#Include\Functions

for the Ahk script

so that a included ahk file with a DllCall function in it could use it like below:
Code:
Result := DllCall(%A_IncludeDllDir%\CtrlSupport\MyDllFunction, ....)


which might be included in a users script by adding a couple of lines like so:
Code:
#Include, %A_IncludeDir%\Functions\CtrlSupport\TreeCtrl.ahk

which would of course include all the functions for creating and manipulating the TreeView control.

And maybe one day a built fucntion that looks at a scripts contents when being compiled and adds lines like the following to the autoexe section of a script just before being compiled so when this script leaves home it brings its baggage.
Code:
FileInstall, %A_IncludeDllDir%l\CtrlSupport.dll, %A_ScriptDir%l\CtrlSupport.dll


And why all this? Simply so that scripts can be anywhere and find there dll files if they use them, so that included files can be copied and modified to one personal use and still find the dll file if need be, and so that copies of the dll files are not nessisary unless of course the script is being compiled.

So if you think this is a good idea let me know, if not, let me know that too. And your comments are welcome aswell.
_________________
my lame sig Smile


Last edited by Invalid User on Sun Mar 12, 2006 5:56 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sat Mar 11, 2006 3:40 pm    Post subject: Reply with quote

Ouch, sorry, I am a bit tired, so I didn't understood fully your post...
There is just a remark I wanted to make. You wrote: "If the full path is left out it is assumed to be the the working dir of the script."
That's not true, and the manual states it: "If an absolute path isn't specified, DllFile is assumed to be in the system's PATH or A_WorkingDir."
So the DLL can be in the directory of the script (or another if accessed via a shortcut), in the directory of the AutoHotkey.exe, in the Windows directory and any other directory you may have added to the path.
It seems to address a lot of issues. If you don't want to touch the path, you can even put the directory of your DLLs in an environment variable and get it there.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Invalid User



Joined: 14 Feb 2005
Posts: 442
Location: Texas, Usa

PostPosted: Sun Mar 12, 2006 6:23 am    Post subject: Reply with quote

I corrected my post to read A_WorkingDir, But I dont think its nessisary to change the A_WorkingDir during a function that uses dllcall because they might use A_WorkingDir which would then be a different value than expected. Besides, there would still be the need for A_IncludeDir. Thank you.

I didnt think of the EnvSet method, but thats limited to 32kb( not really a problem) but from the help manual
Quote:
An environment variable created or changed with this command will be accessible only to programs the script launches via Run or RunWait. See environment variables for more details.
will probly make that route obsolete. What do you think?
_________________
my lame sig Smile
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Invalid User



Joined: 14 Feb 2005
Posts: 442
Location: Texas, Usa

PostPosted: Mon Mar 13, 2006 2:35 pm    Post subject: Reply with quote

Please delete this thread.
_________________
my lame sig Smile
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Mon Mar 13, 2006 3:22 pm    Post subject: Reply with quote

Well, PhiLho has replied already so might not want it deleted. And perhaps it should be kept for future reference. If so, maybe you could make some final remarks at the bottom of the thread about why it's either obsolete or something you don't wish pursued.
Back to top
View user's profile Send private message Send e-mail
Invalid User



Joined: 14 Feb 2005
Posts: 442
Location: Texas, Usa

PostPosted: Mon Mar 13, 2006 6:58 pm    Post subject: Reply with quote

I guess it can stay... sigh. Surprised
_________________
my lame sig Smile
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group