A "Wraparound" IUnknown so the 3 members got visible.
Since IUnknown Interface (which is the stemfather of most of all the Interfaces in the Shell32 Interfaces I see it abit awkward why just this interface shall be "hidden" within the OleExp TypeLib (It was never hidden within the EnumDeskVB TypeLib from 1998).
Here is a little walkaround to make these 3 members availabale/Visible.
Code:
Public Function GetIUnknown() As oleexp.IUnknown
Dim pISF As IShellFolder
Dim ppISF As Long
Dim pIUnk As oleexp.IUnknown
SHGetDesktopFolder ppISF
MoveMemory pISF, ppISF, 4
Set pIUnk = pISF
Set GetIUnknown = pIUnk
End Function
You can also add a pidl, path or an object to Create a IShellItem and get the IUnknown from there.
Re: A "Wraparound" IUnknown so the 3 members got visible.
Here is another one sample to get the 3 members if you got a Windows that can create IShellItems? (XP+)
Code:
'<<--description
'Public Declare Function SHCreateItemFromParsingName Lib "shell32.dll" (ByVal pszPath As Long, ByVal pIBindCtx As Long, riid As 'Any, ByRef ppv As Any) As Long
'Public Declare Function SHGetItemFromObject Lib "shell32.dll" (ByVal pPunk As Long, riid As Any, ByRef ppsi As Any) As Long
'<<--description
Public Declare Function SHCreateItemFromIDList Lib "shell32.dll" (ByVal pidlAbsolute As Long, riid As GUID, ByRef ppv As IShellItem) As Long
Public Function GetIUnknownFromPidl(ByVal pidl As Long) As oleexp.IUnknown
Dim pISF As IShellFolder
Dim pIUnk As oleexp.IUnknown
Dim pISI As IShellItem
Dim pIPAI As IParentAndItem
'If source is not a pidl, you can cretate a IShellItem from parsing a string to pidl or via a objct. (Theese API's are in the description)
SHCreateItemFromIDList pidl, IID_IShellItem, pISI
Set pIPAI = pISI
pIPAI.GetParentAndItem 0, pISF, 0
Set pIUnk = pISF
Set GetIUnknownFromPidl = pIUnk
End Function
!!! BE AWARE THAT the IUnknown Interface MUST POINT TO A IShellFolder Interface and NOT to a IShellItem Interface!!
Re: A "Wraparound" IUnknown so the 3 members got visible.
I don't understand. What's the use of this?
Re: A "Wraparound" IUnknown so the 3 members got visible.
Because if you use the Falfallone's TypeLib and do like this:
Code:
Dim pIUnk As IUnknown
You don't got the hands of the the 3 basic members because the this Interface is "hidden" inside the Type Lib.
That is not that easy to understand...In the old IEnumDeskVB Type Lib was not IUnknown hidden.
Re: A "Wraparound" IUnknown so the 3 members got visible.
I can't find the reason why he have choosen to make IUnknown, IDispatch and IEnumVARIANT as hidden inside the typelib.
IDispatch is also a crucial "ROOT" Interface you need to make seratin things with.
IEnumVARIANT I have nothing to say about because I haven't need it yet.
Re: A "Wraparound" IUnknown so the 3 members got visible.
How is it hidden in oleexp but not enumdeskvb's typelib? It's literally the same definition. Same attributes. No Hidden attribute.
ISHF_Ex.tlb (EnumDeskVB, comments removed):
Code:
[
uuid(00000000-0000-0000-C000-000000000046),
odl
]
interface IUnknown
{
typedef IUnknown *LPUNKNOWN;
long QueryInterface(
[in] REFIID riid,
[out] void *ppvObject);
ULONG AddRef();
ULONG Release();
}
oleexp:
Code:
[
odl,
uuid(00000000-0000-0000-C000-000000000046),
]
interface IUnknown{
LONG QueryInterface(
[in, out] UUID *riid,
[in, out] void *ppvObject);
LONG AddRef();
LONG Release();
}
You tell me where there's an attribute that's hiding it in my typelib but not in ISHFEx. There's no such attribute. There's no hidden, no restricted, it has the same exact visibility.
If your issue is why it's not on every derived interface, well Brad thought better of it with 1.21, Eduardo had more sense with olelib from the start, it's to make it less tempting to use so we're not inundated with questions that arise from using it improperly (which your code snippet seems purpose designed to lead to), when the actual uses were rare in 1998 and virtually never necessary now. It's just cluttering up intellisense to leave it. Feel free to make your own build of oleexp with it the members appended to everything. Just run a find/replace for ": stdole.IUnknown" -> ": IUnknown" without the quotes. Just change the project GUID in oleexp.odl so it doesn't conflict.
Re: A "Wraparound" IUnknown so the 3 members got visible.
My intention is only to make it more simple to do a QueryInterface from IUnknown.
Since your TypeLib hides IUnknown from the regular "Dim xx as xx", how easy or difficult is it for more novise shell progammers to undestand they MUST use yout type lib in this fashion oleexp.IUnknown then just Dim xx as xx?
You can do it that way but you refuse.
Re: A "Wraparound" IUnknown so the 3 members got visible.
Quote:
Originally Posted by
nebeln
My intention is only to make it more simple to do a QueryInterface from IUnknown.
Since your TypeLib hides IUnknown from the regular "Dim xx as xx", how easy or difficult is it for more novise shell progammers to undestand they MUST use yout type lib in this fashion oleexp.IUnknown then just Dim xx as xx?
You can do it that way but you refuse.
@nebeln: I'm wondering in 6-12 months what your stance on this "problem" would be when you realize there is no point in calling QI outside of built-in variable assignment i.e. Set pInterface = pSourceInterface is the only type of QI usage that makes sense.
You have to have the type of pInterface in a typelib so you can use it for both QI and for anything useful after that. There is rarely a point in calling QI for IIDs of types which are not available to the compiler in a typelib. When you get such "raw" interface you are limited to what you can do with it -- pass it to a function, keep in a Long, use DispCallFunc on it.
Besides, oleexp.IUnknown is not restricted -- you just have to explicitly scope it with oleexp which is nice thing to do for all you declarations so that your code becomes more reusable when someone pastes it in a project of theirs esp. when they have another typelib with interfaces referenced (e.g. stdole already has IUnknown) to prevent collisions on variables/params types.
cheers,
</wqw>
Re: A "Wraparound" IUnknown so the 3 members got visible.
Quote:
Originally Posted by
nebeln
Because if you use the Falfallone's TypeLib and do like this:
Code:
Dim pIUnk As IUnknown
You don't got the hands of the the 3 basic members because the this Interface is "hidden" inside the Type Lib.
That is not that easy to understand...In the old IEnumDeskVB Type Lib was not IUnknown hidden.
Code:
Dim pIUnk As IUnknown ' <-- This IUnknown is from Project -> References -> OLE Automation (contains hidden members)
Code:
Dim pIUnk As oleexp.IUnknown ' <-- This IUnknown is from fafalone's TypeLib (no hidden members)
Re: A "Wraparound" IUnknown so the 3 members got visible.
Quote:
Originally Posted by
nebeln
My intention is only to make it more simple to do a QueryInterface from IUnknown.
Since your TypeLib hides IUnknown from the regular "Dim xx as xx", how easy or difficult is it for more novise shell progammers to undestand they MUST use yout type lib in this fashion oleexp.IUnknown then just Dim xx as xx?
You can do it that way but you refuse.
Novice shell programmers shouldn't be using it at all. wqweto explained it well, I'd just add a confirmation: VB's Set calls QI under the hood; it's not different, you can't get any declared interface with one way but not the other. And definitely not AddRef/Release, since I know you'll be tempted to because EnumDeskVB/VBExplorer does. You've already posted a bunch of questions because you decided you should also use another exotic advanced technique as a matter of course rather than only in unusual circumstances where there's no alternative without a basic understanding of the low level details of COM, and it blew up. (Copying around object pointers).
As I more experienced shell programmer, I don't want those 3 items cluttering up my intellisense list when I virtually never use them and to make me think twice if I really need to, because I too have a strong tendency to play around with low level things when higher level will suffice.
It's one thing to play around with these things, I'm glad to answer questions and help someone learn this very interesting area, but it's a little annoying to carry on about oh I'm hiding something and refusing to do it your way to make it easier for you and others get into trouble because you'll need 2 extra lines of code. I've told you exactly how to modify oleexp to have those members show on everything if you insist on it anyway, just follow it exactly-- include the : and space, and change the GUID to your own unique one.
Re: A "Wraparound" IUnknown so the 3 members got visible.
Dear Faffalone, it was never my intention to anoying you for sure...it was that then something as in this case IUnknown is not visible and is "placed" within your TypeLib and typing oleexp. and is not shown in the droplist I asume it's "hidden" or what I shall call it? If not an object is visible what is it then? Shall I better call it "unvisible" interface?
Re: A "Wraparound" IUnknown so the 3 members got visible.
It's not in the object browser/intellisense in ISHFEx either and you don't think that's hidden. What do you call that?
stdole.IUnknown is hidden in derived interfaces. They don't inherit from oleexp.IUnknown at all. So that leaves the object browser and general intellisense (i.e. libname.? or As ?), where is has identical visibility to ISHFEx.IUnknown (i.e. it's not there).
So since that's as "hidden" as oleexp.IUnknown, and you call that visible, how's about visible?
More formally, things with the hidden attribute are hidden.