#DllLoad proper usage with utility class

Get help for the alpha version of AutoHotkey v2 here. Please state the v2 version you are working with in the title when making a new topic.
User avatar
kczx3
Posts: 1224
Joined: 06 Oct 2015, 21:39

#DllLoad proper usage with utility class

19 Nov 2020, 10:26

What is the proper usage of #DllLoad in a class that uses a Dll? Especially if you want the consumer to be able to pass the path to the Dll. Are there concerns/issues with calling #DllLoad multiple times with the same Dll?
User avatar
TheArkive
Posts: 407
Joined: 05 Aug 2016, 08:06
GitHub: TheArkive

Re: #DllLoad proper usage with utility class

21 Nov 2020, 10:14

I would think that might depend on the DLL. Is the DLL meant to be loaded into multiple instances of itself?

Hopefully the DLL is documented in a way where it is easy-ish to manage instances (assuming it is meant to be spawned that way). Maybe it's meant to be loaded once, and then a built in function/method would then load another instance?

What's the DLL to be loaded?
User avatar
kczx3
Posts: 1224
Joined: 06 Oct 2015, 21:39

Re: #DllLoad proper usage with utility class

21 Nov 2020, 10:48

Its Scintilla. So the Dll only needs to be loaded once per AHK process. But I don't think the #DllLoad should be included in the class that wraps the control. I could probably use the asterisk to avoid issues if the class is included more than once. But then the consumer can't provide the path to the Dll.
User avatar
TheArkive
Posts: 407
Joined: 05 Aug 2016, 08:06
GitHub: TheArkive

Re: #DllLoad proper usage with utility class

21 Nov 2020, 10:54

Ah good point.

Funny, i've been thinking of getting back to scintilla myself...

I thought your original script class had a way to pass a specific path already? Any reason in particular why it should be done through #DllLoad?

Code: Select all

__New(gui, opts := "", DllPath := "Scintilla.dll", Style := 0x50010000, ExStyle := 0x200) {
I would think that in the case of a class script, it is more important to rely on the customer know how to use it, more so than "too much dummy-proofing". Unless, i'm missing a finer point..?
User avatar
kczx3
Posts: 1224
Joined: 06 Oct 2015, 21:39

Re: #DllLoad proper usage with utility class

21 Nov 2020, 20:18

Makes sense. But I think that is sacrificing performance optimizations by calling #DllLoad and calling the functions by name.
User avatar
TheArkive
Posts: 407
Joined: 05 Aug 2016, 08:06
GitHub: TheArkive

Re: #DllLoad proper usage with utility class

22 Nov 2020, 01:38

If you manage to squeeze more performance out of scintilla with any method, I'd be interested :D I still have some experiments to do with custom syntax highlighting.
Helgef
Posts: 4479
Joined: 17 Jul 2016, 01:02
Contact:

Re: #DllLoad proper usage with utility class

29 Nov 2020, 08:50

You can only load a dll once, if I'm not mistaken (disregarding copies). Using #dllload or LoadLibrary() on the same dll multiple times will not create new "instances" of it.
you want the consumer to be able to pass the path to the Dll.
Is the consumer a programmer using the class or a user of a program?

I think I would design a class/library with the assumption that the programmer using it loads the dll as it prefers. This could also require the programmer to delete a #dllload if it doesn't want to use it ;).

Cheers.

Return to “AutoHotkey v2 Help”

Who is online

Users browsing this forum: No registered users and 1 guest