petermat1
Dec 8, 2016
=ABCs of APIs 11 - <span style="background-color: #ffffff;"> Translating documentation for DLLs in MS "C" into Liberty BASIC </span>= //Petermat// [[toc|flat]] ---- =Introduction= I am afraid this note is not by your friendly expert <span style="background-color: #ffffff;">Alyce Watson, but by ignoramus Petermat. Why? Because Alyce did not write this, I needed it, and all I can do is to try to find my way. If I fail maybe someone will be encouraged to pick up and correct the note.</span> <span style="background-color: #ffffff;">Why is the note necessary? Because Microsoft documents it's API's using C / C++ examples</span> <span style="font-size: 1.4em;">**The example I am going to use.**</span> The following LB code is due to <span style="background-color: #ffffff;">Alyce Watson at </span>http://libertybasicuniversity.com/lbnews/nl109/browse.htm. I don't intend to go into the semantics or use of this - just its translation. [[code]]<span style="color: darkblue;">calldllcalldll #shell32, "SHGetPathFromIDList",_ lpIDList as long,_ sPath$ as ptr,_ r aslong</span>long [[code]] The MS definition at https://msdn.microsoft.com/en-us/library/windows/desktop/bb762194(v=vs.85).aspx [[code]]<span style="font-family: Consolas,Courier,monospace; font-size: 14px;">BOOLBOOL SHGetPathFromIDList( _In_ PCIDLIST_ABSOLUTE pidl, _Out_ LPTSTR pszPath );</span>[[code]] This is C++ code. SHGetPathFromIDList is the name of a function - just like LB - and the comma delimited items inside the () are the two function parameters. A C++ function returns a value just like an LB function - which is covered as described in previous notes as the last parameter in the LB call - here it's "r as long". You do have to know that "BOOL" defines the type of the C++ return and that this needs a "long" type in LB. The "_In_" and "_Out_" mean just what you might think. "pidl" is defined as of type "PCIDLIST_ABSOLUTE" and the MS definition "address of an item identifier list" which has to be type long in LB. Much more to come - Petermat