question

jenCarlosLopezReyes-3297 avatar image
0 Votes"
jenCarlosLopezReyes-3297 asked SimpleSamples commented

Translate the IShellWindows interface

Good...

What I want is to translate this interface from c ++ to visual basic.

I tried to translate it, but I had problems with some functions, especially those that depend on VARIANT.

The code
<ComImport(), Guid("85CB6900-4D95-11CF-960C-0080C7F4EE85"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
Public Interface IShellWindows
<PreserveSig>
Function _NewEnum(<Out(), MarshalAs(UnmanagedType.IUnknown)> ByRef ppunk As Object) As HRESULT

       HRESULT FindWindowSW(
   VARIANT   *pvarLoc,
   VARIANT   *pvarLocRoot,
   int       swClass,
   long      *phwnd,
   int       swfwOptions,
   IDispatch **ppdispOut
 );
     <PreserveSig>
     Function get_Count(<Out> ByRef Count As Integer) As HRESULT
    
         HRESULT Item(
   VARIANT   index,
   IDispatch **Folder
 );
     End Function
     <PreserveSig>
     Function OnActivated(ByVal lCookie As Integer, ByVal fActive As Boolean) As HRESULT
     <PreserveSig>
     Function OnCreated(ByVal lCookie As Integer, <Out(), MarshalAs(UnmanagedType.IUnknown)> ByRef punk As Object) As HRESULT
    
       HRESULT OnNavigate(
   long    lCookie,
   VARIANT *pvarLoc
 );
     <PreserveSig>
     Function ProcessAttachDetach(ByVal fAttach As Boolean) As HRESULT
     <PreserveSig>
     Function Register(ByRef pid As IDispatch, ByVal hwnd As IntPtr, ByRef swClass As Integer, ByRef plCookie As Integer) As HRESULT
         <PreserveSig>
             Function  RegisterPending(ByVal    lThreadId As Integer, 
         'VARIANT *pvarloc,
         VARIANT *pvarlocRoot,
      ByVal  swClass as Integer,
   ByRef    plCookie As Integer
 ) As HRESULT
         <PreserveSig>
         Function Revoke(ByVal lCookie As Integer) As HRESULT
     End Interface

I hope you can help me with this problem.

Thank you.


dotnet-visual-basic
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You have a fundamental problem to solve and you think you have a solution and you are asking for help with the solution. It is highly likely there is an easier way to solve the fundamental problem; whatever it is you are trying to do. Part of IShellWindows support the file system and another part is part of Internet Explorer. You appear to be using the Internet Explorer part. What is it that you need to do? Even if you do have to use IShellWindows, there is an easier way to do it than translating the C++.

0 Votes 0 ·

1 Answer

Castorix31 avatar image
1 Vote"
Castorix31 answered SimpleSamples commented

From one of my old codes (I just tested on Windows 10, it still works...) =>

    Public Enum HRESULT As Integer
         S_OK = 0
         S_FALSE = 1
         E_NOINTERFACE = &H80004002
         E_NOTIMPL = &H80004001
         E_FAIL = &H80004005
         E_UNEXPECTED = &H8000FFFF
         E_OUTOFMEMORY = &H8007000E
     End Enum
    
     <InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("85CB6900-4D95-11CF-960C-0080C7F4EE85")>
     Private Interface IShellWindows
 #Region "<IDispatch>"
         Function GetTypeInfoCount(<[Out]()> ByRef pctinfo As UInteger) As HRESULT
         Function GetTypeInfo(iTInfo As UInteger, lcid As UInteger, <[Out]()> ByRef ppTInfo As IntPtr) As HRESULT
    
         Function GetIDsOfNames(ByRef riid As Guid, <[In], MarshalAs(UnmanagedType.LPArray)> rgszNames As String(),
                                <[In], MarshalAs(UnmanagedType.U4)> cNames As Integer,
                                <[In], MarshalAs(UnmanagedType.U4)> lcid As UInteger,
                                <Out, MarshalAs(UnmanagedType.LPArray)> ByRef rgDispId As Integer()) As HRESULT
         Function Invoke(dispIdMember As Integer, ByRef riid As Guid, <[In], MarshalAs(UnmanagedType.U4)> lcid As Integer,
                         <[In], MarshalAs(UnmanagedType.U4)> dwFlags As Integer,
                         <Out, [In]> ByRef pDispParams As System.Runtime.InteropServices.ComTypes.DISPPARAMS,
                         <Out> ByRef pVarResult As Object, <Out, [In]> ByRef pExcepInfo As System.Runtime.InteropServices.ComTypes.EXCEPINFO,
                         <Out, MarshalAs(UnmanagedType.LPArray)> ByRef pArgErr As IntPtr()) As HRESULT
 #End Region
    
         Function get_Count(<[Out]()> ByRef phwnd As Integer) As HRESULT
         Function Item(<[In](), MarshalAs(UnmanagedType.Struct)> ByRef index As Object,
                       <[Out](), MarshalAs(UnmanagedType.IDispatch)> ByRef Folder As Object) As HRESULT
         Function _NewEnum(<[Out](), MarshalAs(UnmanagedType.IUnknown)> ByRef Folder As Object) As HRESULT
         Function Register(<[In](), MarshalAs(UnmanagedType.IDispatch)> ByRef pid As Object,
                           hwnd As Integer, swClass As Integer, <[Out]()> ByRef plCookie As Integer) As HRESULT
         Function RegisterPending(lThreadId As Integer,
                      <[In](), MarshalAs(UnmanagedType.Struct)> ByRef pvarLoc As Object,
                     <[In](), MarshalAs(UnmanagedType.Struct)> ByRef pvarLocRoot As Object,
                     swClass As Integer, <[Out]()> ByRef plCookie As Integer) As HRESULT
         Function Revoke(lCookie As Integer) As HRESULT
         Function OnNavigate(lCookie As Integer, <[In](), MarshalAs(UnmanagedType.Struct)> ByRef pvarLoc As Object) As HRESULT
         Function OnActivated(lCookie As Integer, <[In](), MarshalAs(UnmanagedType.Struct)> ByRef fActive As Object) As HRESULT
         Function FindWindowSW(
                       <[In](), MarshalAs(UnmanagedType.Struct)> ByRef pvarLoc As Object,
                        <[In](), MarshalAs(UnmanagedType.Struct)> ByRef pvarLocRoot As Object,
                        swClass As Integer,
                        <[Out]()> ByRef phwnd As Integer,
                        swfwOptions As Integer,
                        <[Out](), MarshalAs(UnmanagedType.IDispatch)> ByRef ppdispOut As Object) As HRESULT
         Function OnCreated(phwnd As Integer) As HRESULT
         Function ProcessAttachDetach(phwnd As Integer) As HRESULT
     End Interface


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You're great.
Thanks a lot.

0 Votes 0 ·
SimpleSamples avatar image SimpleSamples jenCarlosLopezReyes-3297 ·

I really doubt that is the easiest solution.

1 Vote 1 ·