ctl3d32 Posted July 3, 2009 Share Posted July 3, 2009 (edited) Hi all!I need help using a simple dll i created using MATLAB 2009a named fatorial.dll using MS Visual C++ in MS Visual Studio 2008.I created a "fatorial.m" file with the following code:CODEfunction resultado = fatorial(x)resultado = factorial(x);The code above calculates the factorial of a given number and returns the result in variable "resultado".The code bellow is the graphical AutoIT code:CODE#include <ButtonConstants.au3>#include <EditConstants.au3>#include <GUIConstantsEx.au3>#include <StaticConstants.au3>#include <WindowsConstants.au3>#Include <GuiEdit.au3>#Region ### START Koda GUI section ### Form=$Form1 = GUICreate("Fatorial", 203, 115, -1, -1)$Input1 = GUICtrlCreateInput("", 88, 8, 105, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))$Input2 = GUICtrlCreateInput("", 48, 80, 105, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))$Button1 = GUICtrlCreateButton("Calcular", 64, 40, 75, 25, $WS_GROUP)$Label1 = GUICtrlCreateLabel("Entrada:", 32, 11, 44, 17)GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ###While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $dll = DllOpen("fatorial.dll") DllCall($dll, 0, "fatorialInitialize", "byte", 0) $result = DllCall($dll, "long", 7, "byte", $Input1) DllCall($dll, "none", "fatorialTerminate") DllClose($dll) _GUICtrlEdit_SetText($Input2, $result) EndSwitchWEndHere is the link to download the dll, since it's greater than 64k: fatorial.dllCould someone please help me?Thanks in advance,Denis Pedro Edited July 3, 2009 by ctl3d32 Link to comment Share on other sites More sharing options...
ctl3d32 Posted July 3, 2009 Author Share Posted July 3, 2009 (edited) Updated code, but still not working. CODE#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <GuiEdit.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Fatorial", 203, 115, -1, -1) $Input1 = GUICtrlCreateInput("", 88, 8, 105, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER)) $Input2 = GUICtrlCreateInput("", 48, 80, 105, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) $Button1 = GUICtrlCreateButton("Calcular", 64, 40, 75, 25, $WS_GROUP) $Label1 = GUICtrlCreateLabel("Entrada:", 32, 11, 44, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $dll = DllOpen("fatorial.dll") DllCall($dll, "none", "fatorialInitialize", "byte", 0) $result = DllCall($dll, "dword", "fatorial", "dword", Int(_GUICtrlEdit_GetText($Input1))) DllCall($dll, "none", "fatorialTerminate") DllClose($dll) _GUICtrlEdit_SetText($Input2, $result) EndSwitch WEnd Edited July 3, 2009 by ctl3d32 Link to comment Share on other sites More sharing options...
monoceres Posted July 3, 2009 Share Posted July 3, 2009 Hi! DllCall() returns an array so your return value is in $result[0] Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
ctl3d32 Posted July 5, 2009 Author Share Posted July 5, 2009 Thanks, i will try it. 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