DCCD Posted March 31, 2012 Posted March 31, 2012 Hi everybody, To give you an idea, take a look at this simple example of a message box using DllCall function. $result = DllCall("user32.dll", "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0) The question is how to check if DllCall will work before the message box appear? Thanks & any help would be greatly appreciated.. [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
Moderators Melba23 Posted March 31, 2012 Moderators Posted March 31, 2012 DCCD, Are you trying to see if a dll is present on the machine and ready to use? Perhaps you could make a hidden call to the same dll earlier in the script and see if you get an error response. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
DCCD Posted March 31, 2012 Author Posted March 31, 2012 @Melba23, thanks a lot. let's say i have another Dll has a func that i'd like to use, unfortunately if i call that func and it is being used by another process caused an unexpected error. Actually the DllCall return value has a lot of helpful information about the error but unfortunately too late!. About the hidden call, I tried hard to understand that but no luck! what do you mean by the hidden call? Thanks again.. [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
Moderators Melba23 Posted March 31, 2012 Moderators Posted March 31, 2012 DCCD, I came up with the "hidden call" idea because I thought you were checking for the availabilty of the DLL in general, not just a single function. The idea was that you would just use a simple call to the DLL with no visible effect on your script to see if it returned correctly. As to your actual requirement to check if a specific function is in use - I am afraid I have no idea. But if it is critical, why not put the call into a loop like this pseudo-code: start loop call dll if not error exitloop sleep reloop if we get here then the call succeeded Then you will keep calling until your call is successful.. You may want to add a loop counter and abandon the call if yo get too many failures. Any help? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
trancexx Posted March 31, 2012 Posted March 31, 2012 let's say i have another Dll has a func that i'd like to use, unfortunately if i call that func and it is being used by another process caused an unexpected error.That's nonsense. DllCall() is advanced AutoIt feature for advanced users. The fact that you have managed to construct quoted sentence means you shouldn't be using DllCall() yet. Learn more.As for DLL availability (check even), use DllOpen() function. ♡♡♡ . eMyvnE
jchd Posted March 31, 2012 Posted March 31, 2012 Did you create the offending DLL yourself?If yes, care to show us the full code/data of the DLL function you invoke?If not, which DLL are you talking about and why is it built in such a wrong way that it misbehaves? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
DCCD Posted April 1, 2012 Author Posted April 1, 2012 That's nonsense. DllCall() is advanced AutoIt feature for advanced users. The fact that you have managed to construct quoted sentence means you shouldn't be using DllCall() yet. Learn more. As for DLL availability (check even), use DllOpen() function. Do i really need to use DllOpen() function, to check a specific function?, i don't think so.. Did you create the offending DLL yourself? If yes, care to show us the full code/data of the DLL function you invoke? If not, which DLL are you talking about and why is it built in such a wrong way that it misbehaves? Actually no, it's not mine, there's nothing wrong with the Dll file, it's simple as my first How to get some information or check if MessageBox function exists before the message box appear? DllCall("user32.dll", "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0) @trancexx & @jchd, Thank You, all of you [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
MilesAhead Posted April 1, 2012 Posted April 1, 2012 (edited) See the functions _WinAPI_LoadLibrary() and _WinAPI_GetProcAddress() If you can get the address in the DLL of the procedure, chances are it exists in the DLL. As far as some other program already having a function in use, DLL code is shared but the data is exclusive to each process (aside from specifically created shared data segments etc..) Unless you are manipulating some hardware or have a locked file, it shouldn't matter if some program is using a function in a DLL. Windows calls are almost all in DLLs and many processes use them all the time. Edited April 1, 2012 by MilesAhead My Freeware Page
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