autoitxp Posted May 29, 2011 Share Posted May 29, 2011 Hi When i compile this project and call my dll through Delphi app it works perfectly but using autoit when i call dll it not responding donno why even it returned str project2.exe DllCall("myapp.dll","none" ,StartProject, "str" ,"project2.exe") Delphi code : expandcollapse popupunit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; procedure StartProject(MyFileName: Pchar); stdcall; external 'myapp.dll'; procedure StopProject; stdcall; external 'myapp.dll'; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin StartProject('project2.exe'); end; procedure TForm1.Button2Click(Sender: TObject); begin StopProject; end; end. Link to comment Share on other sites More sharing options...
smartee Posted May 30, 2011 Share Posted May 30, 2011 hi again autoitxp,Why did you abandon When using DllCall, the function name must be enclosed in quotes , try it like this:DllCall("myapp.dll", "none", "StartProject", "str", "project2.exe")Hope this helps,-smartee Link to comment Share on other sites More sharing options...
autoitxp Posted May 30, 2011 Author Share Posted May 30, 2011 sorry i forgotten enclosed quotes "StartProject" but in actual script enclosed properly DllCall("myapp.dll", "none", "StartProject", "str", "project2.exe") still not works no effect on dll Link to comment Share on other sites More sharing options...
Zedna Posted May 30, 2011 Share Posted May 30, 2011 Try this DllCall("myapp.dll", "none:cdecl", "StartProject", "str", "project2.exe") Also check @error and GetLastError Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
smartee Posted May 30, 2011 Share Posted May 30, 2011 ..in actual script enclosed properly..Then the "problem" might be in the function itself, or its declaration, because syntax-wise your DllCall() is sound.-smartee Link to comment Share on other sites More sharing options...
autoitxp Posted May 30, 2011 Author Share Posted May 30, 2011 DllCall("myapp.dll", "none:cdecl", "StartProject", "str", "project2.exe") returned nothing and script terminated . dll is very fine all function working well with my Delphi project. only facing problem when calling through Auto-it Link to comment Share on other sites More sharing options...
smartee Posted May 30, 2011 Share Posted May 30, 2011 What do you see when you run this?$aRet = DllCall("myapp.dll", "none", "StartProject", "str", "project2.exe") MsgBox(64, @ScriptName, "@error: " & @error) Link to comment Share on other sites More sharing options...
Zedna Posted May 30, 2011 Share Posted May 30, 2011 (edited) This gives you detailed error message $aRet = DllCall("myapp.dll", "none", "StartProject", "str", "project2.exe") _GetLastErrorMessage('Result') Func _GetLastErrorMessage($DisplayMsgBox="") Local $ret,$s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll","int","GetLastError") $ret = DllCall("kernel32.dll","int","FormatMessage", _ "int",$FORMAT_MESSAGE_FROM_SYSTEM, _ "ptr",0, _ "int",$ret[0], _ "int",0, _ "ptr",DllStructGetPtr($p), _ "int",4096, _ "ptr",0) $s = DllStructGetData($p,1) $p = 0 If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $s) return $s EndFunc Edited May 30, 2011 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
autoitxp Posted May 30, 2011 Author Share Posted May 30, 2011 (edited) thanks Zednaim getting this Result:The Operation completed successfully Edited May 30, 2011 by autoitxp Link to comment Share on other sites More sharing options...
smartee Posted May 30, 2011 Share Posted May 30, 2011 autoitxp,@error=0 means your DllCall was successful, as you may have figured out by now. However, it obviously doesn't do what you expected, so....the "problem" might be in the function itself, or its declaration.. has some examples if you need them -smartee Link to comment Share on other sites More sharing options...
martin Posted May 30, 2011 Share Posted May 30, 2011 (edited) Since there seems to be nothing wrong with the AutoIt code, and the Delphi example works you must conclude there is something wrong you haven't thought of. Delphi is only 32 bit, so are you compiling AutoIt for 64 bit? Edited May 30, 2011 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
autoitxp Posted May 30, 2011 Author Share Posted May 30, 2011 (edited) auto-it Script 32bit uncompressed not 64bit delphi-dll 32bit i just cannot figure out dll seem works fine using Delphi i rechecked nothing found bad in dll next function it called is this may help u to find problem ? Function StartProjectStru(NextFile : PChar ; Bufx : Pointer) : integer;stdcall; but this func doesn't need to called from autoit. when i tried this way it call dll and works but terminated in secs DllCall("myapp.dll", "none", "StartProject", "str", "project2.exe" ,"ptr", 0) !>20:28:21 AutoIT3.exe ended.rc:-1073741819 Edited May 30, 2011 by autoitxp Link to comment Share on other sites More sharing options...
martin Posted May 30, 2011 Share Posted May 30, 2011 auto-it Script 32bit uncompressed not 64bit delphi-dll 32bit i just cannot figure out dll seem works fine using Delphi i rechecked nothing found bad in dll next function it called is this may help u to find problem ? Function StartProjectStru(NextFile : PChar ; Bufx : Pointer) : integer;stdcall; but this func doesn't need to called from autoit. when i tried this way it call dll and works but terminated in secs DllCall("myapp.dll", "none", "StartProject", "str", "project2.exe" ,"ptr", 0) !>20:28:21 AutoIT3.exe ended.rc:-1073741819 What version of Delphi are you using? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
smartee Posted May 30, 2011 Share Posted May 30, 2011 hi autoitxp, We know the outcome you achieve, and it seems perfect, because we do not know what is expected. The next function called within your Delphi program has little to do with your original DllCall. Rather, I suspect the error lies in what you expect the dll to do once called from AutoIt, not in the DllCall, thus creating the obvious question: What exactly does the procedure do? is it a popup message? does it write to a file? How do you know it isn't being called? Try putting a ShowMessage() as the first line of your procedure, and tell us if you see it -smartee Link to comment Share on other sites More sharing options...
autoitxp Posted May 30, 2011 Author Share Posted May 30, 2011 Borland Delphi second edition v7.2 created in 2006 by LiteApplication http://www.liteapplications.com/ Link to comment Share on other sites More sharing options...
martin Posted May 30, 2011 Share Posted May 30, 2011 Then "str" should be ok for the parameter. 0 for the "ptr" probably upsets the dll though. Are you willing to show or share the code for the dll? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
autoitxp Posted May 30, 2011 Author Share Posted May 30, 2011 (edited) -smartee your ShowMessage() trick worked i found Delphi first loads this func Function NtQuerySystemInformation(infoClass: DWORD; buffer: Pointer; bufSize: DWORD; returnSize: TPDWord): DWORD; stdcall; I Put ShowMessage() in start of all function and delphi load this first and auto-it just didn't popped up message when i called dll it means i need to define separately to call NtQuerySystemInformation first then StartProject ? Edited May 30, 2011 by autoitxp Link to comment Share on other sites More sharing options...
autoitxp Posted May 30, 2011 Author Share Posted May 30, 2011 I called this function it pop up message and stops now what next how to to call StartProject? Global Const $SystemProcessInformation = 5 DllCall("mydll.dll", "int", "NtQuerySystemInformation", _ "int", $SystemProcessInformation, _ "ptr", 0, _ "int", 0, _ "int*", 0) Link to comment Share on other sites More sharing options...
JohnOne Posted May 30, 2011 Share Posted May 30, 2011 SystemInformation [in, out] A pointer to a buffer that receives the requested information. The size and structure of this information varies depending on the value of the SystemInformationClass parameter: SYSTEM_BASIC_INFORMATION When the SystemInformationClass parameter is SystemBasicInformation, the buffer pointed to by the SystemInformation parameter should be large enough to hold a single SYSTEM_BASIC_INFORMATION structure having the following layout: Copy typedef struct _SYSTEM_BASIC_INFORMATION { BYTE Reserved1[24]; PVOID Reserved2[4]; CCHAR NumberOfProcessors; } SYSTEM_BASIC_INFORMATION; The NumberOfProcessors member contains the number of processors present in the system. Use GetSystemInfo instead to retrieve this information. The other members of the structure are reserved for internal use by the operating system. You seen to be passing a null pointer to that param. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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