slax Posted July 23, 2009 Share Posted July 23, 2009 (edited) Hello everyone, I have been using autoit for a year but i 've never tried using dlls until now. Well, now i would like to know what is the quickest way of using dll files (calling functions in them). Currently in order to use a dll I use this code: $dll = DllOpen ("whatever.dll") ... DllCall($dll, "return type", "Function", "type1", "param1") Because the DllCall function is in a loop I need it to be done as quickly as possible. So here is my question: Is there a way of calling dll fuctions more quickly? Thanks in advance Edited July 23, 2009 by slax Link to comment Share on other sites More sharing options...
KaFu Posted July 23, 2009 Share Posted July 23, 2009 (edited) Open the DLL before the loop and close it afterwards. I preferably open them on program start and close them on program exit. I guess more speed improvement can be achived if you load the DLL to memory, search examples section. Edited July 23, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
slax Posted July 23, 2009 Author Share Posted July 23, 2009 First of all thanks for your reply. That's what I am doing. I open the dll on program start and not in the loop. That is what the three dots mean. :-) Link to comment Share on other sites More sharing options...
monoceres Posted July 23, 2009 Share Posted July 23, 2009 The speed you achieve with your code is more than enough for most applications (just take a look at the standard library, everything is done with dllcall there).If you really truly want more speed and know at least some basic assembly then take a look at the various assembly/machine code example spread around the forums ( I believe trancexx call it flying assembly). However everyone did just fine without it before so I doubt you will realy need it.I guess more speed improvement can be achived if you load the DLL to memory, search examples section.What exactly do you think happens when you use DllOpen()? Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
KaFu Posted July 23, 2009 Share Posted July 23, 2009 DLLOpen(): "Success: Returns a dll "handle" to be used with subsequent Dll functions." Had assumed that the DLL is "opened" and a "handle" for communication is created... but from your implicit reply I now assume it's loaded to memory? I'm always willing to learn as a pure spare time "coder"... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
monoceres Posted July 23, 2009 Share Posted July 23, 2009 Yes, just like when you run an exe the entire image gets loaded into system memory and begins to execute at its entry point. The difference between an exe and a dll is that windows maps dll's into the address space of other processes instead of (like exe's) in their own space. So the dll gets loaded into memory even without the use of DllOpen it's just autoit that hides the loading/unloading each time. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now