petermat1
Dec 8, 2016
ABCs of APIs 11 - Translating documentation for DLLs in MS "C" into Liberty BASIC
PetermatABCs of APIs 11 - 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.Why is the note necessary? Because Microsoft documents it's API's using C / C++ examples
The example I am going to use.
The following LB code is due to
<spanstyle="font-size: 1.1em;">BIF.RETURNONLYFSDIRS = 1MAX.PATH = 260STRUCT BrowseInfo,_hWndOwner As uLong,_pIDLRoot As Long,_pszDisplayName As Long,_lpszTitle$ As ptr,_ulFlags As Long,_lpfnCallback As Long,_lParam As Long,_iImage As Long'Set the owner window, optionalBrowseInfo.hWndOwner.struct = 0BrowseInfo.lpszTitle$.struct = text$'Return only if the user selected a directoryBrowseInfo.ulFlags.struct = BIF.RETURNONLYFSDIRS'Show the 'Browse for folder dialogcalldll #shell32, "SHBrowseForFolder",_BrowseInfo as struct,_lpIDList as longIf lpIDList>0 ThensPath$ = space$(MAX.PATH) + chr$(0)'Get the path from the IDListcalldll #shell32, "SHGetPathFromIDList",lpIDList as long,sPath$ as ptr,r as longopenstyle="color: darkblue;">open "ole32" for dll as #ole
'Free'free the block of memory
calldll #ole, "CoTaskMemFree",_
lpIDList as long,_
r as long
close #ole
iNull = InStr(sPath$, chr$(0))If iNull Then sPath$ = Left$(sPath$, iNull - 1)End Ifprint sPath$
</span>
<span style="font-family: Consolas,Courier,monospace; font-size: 14px;">BOOL SHGetPathFromIDList(
_In_ PCIDLIST_ABSOLUTE pidl,
_Out_ LPTSTR pszPath
);
</span>