Leo1906 Posted May 16, 2017 Share Posted May 16, 2017 I am currently experimenting with DLLCalls and was wondering how I can get a custom Dataformat back? The call goes like this: GDALDatasetH CPL_DLL CPL_STDCALL GDALOpenEx( const char* pszFilename, unsigned int nOpenFlags, const char* const* papszAllowedDrivers, const char* const* papszOpenOptions, const char* const* papszSiblingFiles ) This is taken out of the header file (c++) of the Dll. So the return value is a GDALDataset. How can I save this returned value into a variable in Autoit so that I can access it later on in another function call? I tried like this: $struct = DllStructCreate("GDALDataset *poDS;") $ret = DllCall($dll, DllStructGetPtr($struct), "GDALOpenEx", "char", "D:\Bundeslaender.shp", "int", "0x04", "char", "", "char", "", "char", "") But this wont seem to work. Any suggestions? Kind regards, Leo1906 Link to comment Share on other sites More sharing options...
Danyfirex Posted May 16, 2017 Share Posted May 16, 2017 Hello. It should be something like this. Local $aRet=DllCall("myDll","ptr","GDALOpenEx","str",$pszFilename,"uint",$nOpenFlags,"str",$papszAllowedDrivers,"str",$papszOpenOptions,"str",$papszSiblingFiles) Local $pGDALDatasetH=$aRet[0] Saludos 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...
Leo1906 Posted May 16, 2017 Author Share Posted May 16, 2017 Ok, thanks for that Another question: how do I pass a NULL argument? In C++ I call this function like this: GDALOpenEx(shapefile, GDAL_OF_VECTOR, NULL, NULL, NULL); So my DllCall is like this? $ret = DllCall($dll, "ptr", "_GDALOpenEx@0", "str", "D:\\Bundeslaender.shp", "uint", "0x04", "str", "NULL", "str", "NULL", "str", "NULL") or like this? $ret = DllCall($dll, "ptr", "_GDALOpenEx@0", "str", "D:\\Bundeslaender.shp", "uint", "0x04", "str", "", "str", "", "str", "") Link to comment Share on other sites More sharing options...
Danyfirex Posted May 16, 2017 Share Posted May 16, 2017 (edited) like this would be ok. $ret = DllCall($dll, "ptr", "_GDALOpenEx@0", "str", "D:\\Bundeslaender.shp", "uint", 0x04, "str", NULL, "str", NULL, "str", NULL) Edit Saludos Edited May 16, 2017 by Danyfirex edit 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...
Leo1906 Posted May 17, 2017 Author Share Posted May 17, 2017 Thanks a lot for your help. It seems to work now Another question related to this. In this DLL are some functions which aren't called by passing arguments. For example: int GDALDataset::GetLayerCount() This is the function I want to call using the GDALDataset created in the step before. Return is an integer. In C++ the call is very simple as you may imagine: int i = GDALDataset.GetLayerCount(); How can I call this function using Autoit? This wont work, I think maybe because the function is not expecting some arguments? $ret = DllCall($dll, "int", "GetLayerCount", "ptr", $ret[0]) Link to comment Share on other sites More sharing options...
Danyfirex Posted May 17, 2017 Share Posted May 17, 2017 Hello. Just past nothing. $ret = DllCall($dll, "int", "GetLayerCount") $int=$ret[0] Saludos 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...
Leo1906 Posted May 17, 2017 Author Share Posted May 17, 2017 (edited) Ok, if I pass nothing than it takes the object created by previous DLLCall? Another question. I think that the priour DLLCall is still not correct. This is how it's done in C++: GDALDataset *poDS; poDS = (GDALDataset*)GDALOpenEx(shapefile, GDAL_OF_VECTOR, NULL, NULL, NULL); So, as you're executing the Open Command you cast the return to a pointer of the class? I don't know if I am saying it correctly. Do you think that doing this call in Autoit would be this one here?: $ret = DllCall($dll, "ptr", "GDALOpenEx", "str", "D:\Bundeslaender.shp", "uint", 0x04, "str", NULL, "str", NULL, "str", NULL) Edited May 17, 2017 by Leo1906 Link to comment Share on other sites More sharing options...
Danyfirex Posted May 17, 2017 Share Posted May 17, 2017 You will get return depends of the return type you use in the return parameter. You will get a ptr in that call. I'm no sure about the casting you will need to do because I dont know what lib are you using. Please share the documentation. Saludos 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...
Leo1906 Posted May 17, 2017 Author Share Posted May 17, 2017 I'm using GDAL: http://www.gdal.org/classGDALDataset.html#a9cb8585d0b3c16726b08e25bcc94274a in the current up-to-date version. I was using this in C++ a few times but now I want to learn more about Autoit and DLLCall's and thought that using this library could be a good way to start. Also when I learned enough I thought about maybe making a UDF to GDAL .. but thats somewhere far in the future Link to comment Share on other sites More sharing options...
Danyfirex Posted May 17, 2017 Share Posted May 17, 2017 You need to use the C version instead C++. for getting GDALDatasetH the Opaque type used for the C bindings of the C++ GDALDataset class. Saludos 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...
Leo1906 Posted May 17, 2017 Author Share Posted May 17, 2017 I don't really understand. So I need to download the C sourcecode and compile it to C DLL's or what? Link to comment Share on other sites More sharing options...
Danyfirex Posted May 17, 2017 Share Posted May 17, 2017 I really dont know. I need to check doc. I'll check later when I got some free time. Saludos Leo1906 1 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