I am afraid this note is not by your friendly expert 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. (This is a wiki, right?). Why is the note necessary? Because Microsoft documents it's API's using C / C++ examples
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 of this is "address of an item identifier list" which has to be type long in LB.
Looking at this code we see that the return is of type "PIDLIST" (whatever that is), and there is one parameter which is used as an input by function
SHBrowseForFolder. The definition is headed "The Windows ShellShell ReferenceShell Functions" which is the clue we are still working with shell32.dll, so we can continue to use #shell32 in our LB code. The definition tells us that type LPBROWSEINFO is "A pointer to a BROWSEINFO structure" - which at least tells us it is of type struct from an LB perspective. And lastly, the definition states that the return " a PIDL that specifies the location of the selected folder"
calldll #shell32, "SHBrowseForFolder",_
lbpi struct,_
result as
ABCs of APIs 11.1 - Translating documentation for DLLs in MS "C" into Liberty BASIC
PetermatABCs of APIs 11.1 - Translating documentation for DLLs in MS "C" into Liberty BASIC | Introduction
Introduction
I am afraid this note is not by your friendly expert 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. (This is a wiki, right?).Why is the note necessary? Because Microsoft documents it's API's using C / C++ examples
The First Example.
The following LB code is due to Alyce Watson at http://libertybasicuniversity.com/lbnews/nl109/browse.htm.
I don't intend to go into the semantics or use of this - just its translation.
calldll #shell32, "SHGetPathFromIDList",_ lpIDList as long,_ sPath$ as ptr,_ r as longThe MS definition at https://msdn.microsoft.com/en-us/library/windows/desktop/bb762194(v=vs.85).aspxThis 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 of this is "address of an item identifier list" which has to be type long in LB.
The Second Example.
Now let's start with the C++ definition and code from https://msdn.microsoft.com/en-us/library/windows/desktop/bb762115(v=vs.85).aspx
Looking at this code we see that the return is of type "PIDLIST" (whatever that is), and there is one parameter which is used as an input by function
SHBrowseForFolder. The definition is headed "The Windows Shell Shell Reference Shell Functions" which is the clue we are still working with shell32.dll, so we can continue to use #shell32 in our LB code. The definition tells us that type LPBROWSEINFO is "A pointer to a BROWSEINFO structure" - which at least tells us it is of type struct from an LB perspective. And lastly, the definition states that the return " a PIDL that specifies the location of the selected folder"
calldll #shell32, "SHBrowseForFolder",_ lbpi struct,_ result asAll very well - but what about this struct?More to come - Petermat
SHBrowseForFolder