Xand3r Posted April 9, 2009 Share Posted April 9, 2009 (edited) i made a simple dll in visual c++ 2008 and tried to call the functions in autoit and ran into a problem if i call a func with no parameters(void) it works just fine but when i pass any kind of parameters i get an error from windows saying that autoit has stopped working os:windows vista x64 sp2 autoit:3.3.0.0 $dll = DllOpen(@ScriptDir & "\mumu.dll") $a = 123 $s = DllCall($dll, "int", "test1") MsgBox(0, @error, $s[0]) $s = DllCall($dll, "int", "test2","int" , 0) MsgBox(0, @error, $s[0]) #include <stdio.h> #define _export __declspec(dllexport) extern "C" { __declspec(dllexport) int test1(){ return 100; } __declspec(dllexport) int test2(int z){ return z; } }mumu.dll Edited April 9, 2009 by TheMadman Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
ProgAndy Posted April 9, 2009 Share Posted April 9, 2009 you declare your functions as extern "C". So you have to use cdel in AutoIt, i think: $s = DllCall($dll, "int:cdecl", "test2","int" , 0) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
trancexx Posted April 9, 2009 Share Posted April 9, 2009 (edited) Not only that, but you need to do it like this: #include <WinAPI.au3> #include <Constants.au3> ;$dll = DllOpen(@ScriptDir & "\mumu.dll") _WinAPI_LoadLibraryEx(@ScriptDir & "\mumu.dll", $DONT_RESOLVE_DLL_REFERENCES) $a = 123 $s = DllCall(@ScriptDir & "\mumu.dll", "int:cdecl", "test1") ConsoleWrite(@error & @CRLF) MsgBox(0, @error, $s[0]) $s = DllCall(@ScriptDir & "\mumu.dll", "int:cdecl", "test2","int" , 5) MsgBox(0, @error, $s[0]) Entry point is messed up. That's not good. edit: This example indicates that AutoIt will, if you pass string to DllCall() function, first call GetModuleHandle function and then LoadLibrary to load module. Edited April 9, 2009 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Authenticity Posted April 9, 2009 Share Posted April 9, 2009 I think he needs also to make a .def file and specify it in the input command line of the environment compiler (Visual C++ right?) because otherwise the function's name is strange because of name decoration. Link to comment Share on other sites More sharing options...
Xand3r Posted April 9, 2009 Author Share Posted April 9, 2009 Not only that, but you need to do it like this: #include <WinAPI.au3> #include <Constants.au3> ;$dll = DllOpen(@ScriptDir & "\mumu.dll") _WinAPI_LoadLibraryEx(@ScriptDir & "\mumu.dll", $DONT_RESOLVE_DLL_REFERENCES) $a = 123 $s = DllCall(@ScriptDir & "\mumu.dll", "int:cdecl", "test1") ConsoleWrite(@error & @CRLF) MsgBox(0, @error, $s[0]) $s = DllCall(@ScriptDir & "\mumu.dll", "int:cdecl", "test2","int" , 5) MsgBox(0, @error, $s[0]) Entry point is messed up. That's not good. tnx alot guys Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
trancexx Posted April 10, 2009 Share Posted April 10, 2009 You are marking this as [resolved], but DONT_RESOLVE shouldn't be considered as a real resolver.Resolving this requires of you to resolve it on a different level. There could be more people with similar unresolved problems and they could try to resolve it like it's resolved here and that would likely create new unresolved... things.I could use "resolve" couple of times more in this post but I won't. ♡♡♡ . eMyvnE 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