Danyfirex Posted April 13, 2012 Share Posted April 13, 2012 Hi mates, today I'm trying to learn how API work but I'm not able to make it work. I'm new using WIndows API.I trying with this but does not work.DllCall("kernel32.dll","nonzero","DeleteFile","long int","C:\Users\usuario\Desktop\1.txt")I know that there are many better ways to do this but I want to learn with API.I can't find some tutorial about API for autoit using. Sorry for my bad english. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
JohnOne Posted April 13, 2012 Share Posted April 13, 2012 DllCall("kernel32.dll","int","DeleteFile","str","C:UsersusuarioDesktop1.txt")Maybehttp://msdn.microsoft.com/en-us/library/windows/desktop/aa363915(v=vs.85).aspx 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...
Danyfirex Posted April 13, 2012 Author Share Posted April 13, 2012 (edited) thank you very much work.can you recommend me something to know what types like "str" should I choose?because I thought that the types were these char short int(short) int long int (long) bool float double long double wchar_t or is there one for autoit?Thank you Edited April 13, 2012 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
rodent1 Posted April 13, 2012 Share Posted April 13, 2012 (edited) Hi Danyfirex, if you look at the AutoIT help, you will see that the 2nd argument should be the return type of the API. If I remember correctly, the return type is an 8-bit boolean. So instead of "nonzero", you could have "BOOLEAN". (from the help) Valid Types are: Type............Details ... BOOLEAN....an unsigned 8 bit integer Then the 4th parameter should be the argument type (LPCSTR in C), which for autoit should just be "str": (from the help) Conversions from Windows API types to AutoIt types: WINDOWS API Type........AutoIt Type LPCSTR/LPSTR...............str Then you want to make sure that you are really using the dll. It may not be found, it may give errors, etc. So to do that, I would advise to do it in 2 steps: first, open the dll and get a handle, then use DLLCall with the handle. step 1: Dim $Dll = DllOpen ( "C:MyFolderMyDLL.dll" ) after that you can verify the $Dll value and make sure it's valid, with something like "msgbox(0,"",$Dll) if it is not valid (returns a "-1") it probably did not find (typo in the path), or could not open the dll. If it is valid ($Dll > -1), do the call with something like Dim $Response = DllCall ( $Dll, "BOOLEAN", "DeleteFile", "str", "C:MyOtherFolderMyFileToDelete") Good luck oops, it looks like others posted while I was writing this... Edited April 13, 2012 by rodent1 Link to comment Share on other sites More sharing options...
Danyfirex Posted April 13, 2012 Author Share Posted April 13, 2012 thank you rodent1. I understand. So I going to read about Conversions from Windows API types to AutoIt types.and need to impruve my english to understand that long english documentation. thank you mates. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Zedna Posted April 13, 2012 Share Posted April 13, 2012 (edited) You can also look into WinAPI (and other) standard include files sources to see how DllCall for Windows API functions are used and compare it to original MSDN documentation for these API functions.C:Program FilesAutoIt3IncludeWinAPI.au3EDIT:also look here Edited April 13, 2012 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
KaFu Posted April 13, 2012 Share Posted April 13, 2012 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...
Danyfirex Posted April 14, 2012 Author Share Posted April 14, 2012 Thank you Zenda and KaFu. that helps me so much. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Zedna Posted April 14, 2012 Share Posted April 14, 2012 Thank you Zenda and KaFu. that helps me so much. Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Danyfirex Posted April 14, 2012 Author Share Posted April 14, 2012 (edited) Zedna sorry Zedna. Edited April 14, 2012 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Danyfirex Posted April 14, 2012 Author Share Posted April 14, 2012 (edited) I got some doubt about tutorial " Dealing_with_Dll" about "wstr","C:","dword*", I think, it should be str becauseConversions from Windows API types to AutoIt types : LPCSTR/LPSTR = strand MSDN saysBOOL WINAPI GetDiskFreeSpace( __in LPCTSTR lpRootPathName, __out LPDWORD lpSectorsPerCluster, __out LPDWORD lpBytesPerSector, __out LPDWORD lpNumberOfFreeClusters, __out LPDWORD lpTotalNumberOfClusters); this code of tutorial.; Variables to pass as reference Local $SectorsPerCluster Local $BytesPerSector Local $NumberOfFreeClusters Local $TotalNumberOfClusters $calldata=DllCall("Kernel32.dll","int","GetDiskFreeSpaceW","wstr","C:","dword*",$SectorsPerCluster,"dword*",$BytesPerSector,"dword*",$NumberOfFreeClusters,"dword*",$TotalNumberOfClusters) ; The data is returned as an array, even the changed values of the variables $SectorsPerCluster=$calldata[2] $BytesPerSector=$calldata[3] $NumberOfFreeClusters=$calldata[4] $TotalNumberOfClusters=$calldata[5] MsgBox(0,"","Total number of clusters: "&$TotalNumberOfClusters) Edited April 14, 2012 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
KaFu Posted April 14, 2012 Share Posted April 14, 2012 (edited) Yeah, that's something not so obvious. In the beginning the Windows API was pure ANSI, but in time the need for Unicode support grew overwhelming. The default documentation is in most cases still ANSI, but take a look at the bottom of the MSDN article where it says GetDiskFreeSpaceW (Unicode). Drive letters are obviously always Ansi, but afaik you also can check the freespace on sever hdds with this, and thoses paths might contain Unicode characters. So it's always better to call a Unicode version (is there any reason to call the Ansi version at all?) and replace the str parameter with wstr (of course always check if there is a Unicode version of the function available and if it might make sense to use unicode). Edited April 14, 2012 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...
ProgAndy Posted April 14, 2012 Share Posted April 14, 2012 In the beginning the Windows API was pure ANSI, but in time the need for Unicode support grew overwhelming. The default documentation is in most cases still ANSI, but take a look at the bottom of the MSDN article where it says GetDiskFreeSpaceW (Unicode).That is not always correct, please read the parameter type carefully:LPSTR / LPCSTR / char* --> str, regardless of th function nameLPWSTR / LPCWSTR / wchar_t* --> wstr, regardless of function nameLPTSTR / LPCTSTR / TCHAR* --> str for ANSI calls (no suffix or ...A, e.g. LoadLibray, LoadLibraryA)... but wstr for UNICODE calls (suffix ...W, e.g. LoadLibraryW) *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...
KaFu Posted April 14, 2012 Share Posted April 14, 2012 Did not know that, thanks for the clarification ! 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...
Danyfirex Posted April 14, 2012 Author Share Posted April 14, 2012 ok now I understand, thank you for helping me thank mates. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut 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