-
Notifications
You must be signed in to change notification settings - Fork 9
Description
This should return LongPtr I believe (it is PVOID)
Also I wonder how you would feel about 2 (or 3) improvements to make this more idiomatic:
In my code, I have declared this as
Sub GetDocumentation(ByVal memid As MEMID, Optional ByRef pBstrName As String, Optional ByRef pBstrDocString As String = vbNullString, Optional ByRef pdwHelpContext As Long, Optional ByRef pBstrHelpFile As String)with 2 changes: The Optional arguments, since these are optional from the API point of view. You can specify default of =vbNullString and =NULL_PTR or =0 if needed
Second change is I do
Public Enum MEMID
[_]
End EnumThis does a sort of typedef for DWORD types which improves readability IMO
3rd change is I rename parameters to for example
Sub GetDocumentation(ByVal memid As MEMID, Optional ByRef outName As String, ...)Since ByRef pBstrName to me is
- Too much information; I don't need to know about Bstr as a VBA developer, just String
ByRefandpboth mean kinda the same thing, doubling up makes me expect to get a pointer to a string out, not just a string- I think the
outParamprefix is good from a VBA consumer point of view to make it clear. Attributes may be better in future tB.
I think this may be a harder sell as it is backwards incompatible for your library interface. However in my experience when I declare the APIs this way it makes me much less likely to need to look at the MSDN documentation. But it's still easy to look up online even if I've renamed the params, the function name is the same and the order of params is the same. Maybe for version 3.x of your package.