How do I search an ActiveX/COM object for a method?












1















I have an ActiveX/COM DLL. It contains many methods and properties. I would like to be able to ask it if it has a particular symbol, as per the following snippet:



If HasMethod( "StdLib.DLL", "ReadFileE" ) Then
...
End If


Is there a way to do this from, say, VBScript or JScript? If not, where do I go to get the information I need?










share|improve this question





























    1















    I have an ActiveX/COM DLL. It contains many methods and properties. I would like to be able to ask it if it has a particular symbol, as per the following snippet:



    If HasMethod( "StdLib.DLL", "ReadFileE" ) Then
    ...
    End If


    Is there a way to do this from, say, VBScript or JScript? If not, where do I go to get the information I need?










    share|improve this question



























      1












      1








      1


      1






      I have an ActiveX/COM DLL. It contains many methods and properties. I would like to be able to ask it if it has a particular symbol, as per the following snippet:



      If HasMethod( "StdLib.DLL", "ReadFileE" ) Then
      ...
      End If


      Is there a way to do this from, say, VBScript or JScript? If not, where do I go to get the information I need?










      share|improve this question
















      I have an ActiveX/COM DLL. It contains many methods and properties. I would like to be able to ask it if it has a particular symbol, as per the following snippet:



      If HasMethod( "StdLib.DLL", "ReadFileE" ) Then
      ...
      End If


      Is there a way to do this from, say, VBScript or JScript? If not, where do I go to get the information I need?







      dll scripting activex tlbinf32






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 20:52









      DaveInCaz

      3,07131735




      3,07131735










      asked May 13 '09 at 6:06









      bugmagnetbugmagnet

      4,245645109




      4,245645109
























          3 Answers
          3






          active

          oldest

          votes


















          1














          After Googling around not quite finding what I wanted, I remembered the Edanmo site which got me thinking about TLBINF32.DLL, downloading Microsoft's TLBINF32.CHM and reading up on GetMembersWithSubStringEx. Below is the implementation of it (done in VB6 with a reference to TLBINF32.DLL), some demo VBScript and output, and the wrapping of that functionality in some VBA.



          Public Function SearchTLIMethodsAndProperties(sTypelib As Variant, sSymbol As Variant) As Variant
          Dim SI As SearchItem
          Dim aResults As Variant
          Dim bFound as boolean
          Dim Groups(1) As InvokeKinds
          Groups(0) = INVOKE_FUNC Or INVOKE_PROPERTYGET Or _
          INVOKE_PROPERTYPUT Or INVOKE_PROPERTYPUTREF

          ReDim aResults(0)
          bFound = False
          With TypeLibInfoFromFile(sTypelib)
          .SearchDefault = tliStClasses Or tliStEvents
          For Each SI In .GetMembersWithSubStringEx(sSymbol, Groups)
          bFound = True
          arr.AAdd_PostIncrement aResults, SI.Name
          Next
          End With
          if bFound then
          ReDim Preserve aResults(UBound(aResults) - 1)
          end if
          SearchTLIMethodsAndProperties = aResults
          End Function


          VBScript demo. The above code was included in my StdLib DLL in the Registry coclass.



          Dim O, R
          Set O = CreateObject("Std.Registry")
          Set R = CreateObject("Std.Arrays")
          WScript.Echo R.ShowStructure( O.SearchTLIMethodsAndProperties( "MSSCRIPT.OCX",""))


          Output from the demo (script was run in SciTE).



          >cscript "C:foofoo.vbs"
          {Add,AddCode,AddObject,AllowUI,Clear,CodeObject,Column,Count,Description,Error,Eval,ExecuteStatement,HasReturnValue,HelpContext,HelpFile,Item,Language,Line,Modules,Name,NumArgs,Number,Procedures,Reset,Run,SitehWnd,Source,State,Text,Timeout,UseSafeSubset}
          >Exit code: 0


          Finally, the VBA code. A cell has a symbol in it and this routine finds it or returns an error string.



          Public Function LookupSymbol(sSym As String) As String
          Dim aRes As Variant
          aRes = reg.SearchTLIMethodsAndProperties("MSSCRIPT.OCX", sSym)
          Dim i As Integer
          LookupSymbol = "!!NotFound!!"
          For i = 0 To UBound(aRes)
          If LCase$(aRes(i)) = LCase$(sSym) Then
          LookupSymbol = sSym
          Exit For
          End If
          Next
          End Function


          Looking back on it now, I think I might pass in the path to the DLL/OCX as the first parameter.






          share|improve this answer































            0














            I have used Microsofts interactive OLE/COM-Object viewer to find mehods and their parameters in ActiveX-DLLs. Maybe looking at the source code of the viewer will lead you in the right direction: MSDN OleView sample






            share|improve this answer































              0














              If you want to do it programmatically - I'm not aware of a simple way to do that. Anyway, if you really need to (and if your programming language is capable enough) - you can query the type library (refer to ITypeLib description somewhere at http://msdn.microsoft.com/en-us/library/ms221549.aspx).



              Also, if you already have an IDispatch pointer - you might consider using its services to dynamically enumerate methods supported by the interface (refer to IDispatch description in MSDN).






              share|improve this answer























                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f856309%2fhow-do-i-search-an-activex-com-object-for-a-method%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1














                After Googling around not quite finding what I wanted, I remembered the Edanmo site which got me thinking about TLBINF32.DLL, downloading Microsoft's TLBINF32.CHM and reading up on GetMembersWithSubStringEx. Below is the implementation of it (done in VB6 with a reference to TLBINF32.DLL), some demo VBScript and output, and the wrapping of that functionality in some VBA.



                Public Function SearchTLIMethodsAndProperties(sTypelib As Variant, sSymbol As Variant) As Variant
                Dim SI As SearchItem
                Dim aResults As Variant
                Dim bFound as boolean
                Dim Groups(1) As InvokeKinds
                Groups(0) = INVOKE_FUNC Or INVOKE_PROPERTYGET Or _
                INVOKE_PROPERTYPUT Or INVOKE_PROPERTYPUTREF

                ReDim aResults(0)
                bFound = False
                With TypeLibInfoFromFile(sTypelib)
                .SearchDefault = tliStClasses Or tliStEvents
                For Each SI In .GetMembersWithSubStringEx(sSymbol, Groups)
                bFound = True
                arr.AAdd_PostIncrement aResults, SI.Name
                Next
                End With
                if bFound then
                ReDim Preserve aResults(UBound(aResults) - 1)
                end if
                SearchTLIMethodsAndProperties = aResults
                End Function


                VBScript demo. The above code was included in my StdLib DLL in the Registry coclass.



                Dim O, R
                Set O = CreateObject("Std.Registry")
                Set R = CreateObject("Std.Arrays")
                WScript.Echo R.ShowStructure( O.SearchTLIMethodsAndProperties( "MSSCRIPT.OCX",""))


                Output from the demo (script was run in SciTE).



                >cscript "C:foofoo.vbs"
                {Add,AddCode,AddObject,AllowUI,Clear,CodeObject,Column,Count,Description,Error,Eval,ExecuteStatement,HasReturnValue,HelpContext,HelpFile,Item,Language,Line,Modules,Name,NumArgs,Number,Procedures,Reset,Run,SitehWnd,Source,State,Text,Timeout,UseSafeSubset}
                >Exit code: 0


                Finally, the VBA code. A cell has a symbol in it and this routine finds it or returns an error string.



                Public Function LookupSymbol(sSym As String) As String
                Dim aRes As Variant
                aRes = reg.SearchTLIMethodsAndProperties("MSSCRIPT.OCX", sSym)
                Dim i As Integer
                LookupSymbol = "!!NotFound!!"
                For i = 0 To UBound(aRes)
                If LCase$(aRes(i)) = LCase$(sSym) Then
                LookupSymbol = sSym
                Exit For
                End If
                Next
                End Function


                Looking back on it now, I think I might pass in the path to the DLL/OCX as the first parameter.






                share|improve this answer




























                  1














                  After Googling around not quite finding what I wanted, I remembered the Edanmo site which got me thinking about TLBINF32.DLL, downloading Microsoft's TLBINF32.CHM and reading up on GetMembersWithSubStringEx. Below is the implementation of it (done in VB6 with a reference to TLBINF32.DLL), some demo VBScript and output, and the wrapping of that functionality in some VBA.



                  Public Function SearchTLIMethodsAndProperties(sTypelib As Variant, sSymbol As Variant) As Variant
                  Dim SI As SearchItem
                  Dim aResults As Variant
                  Dim bFound as boolean
                  Dim Groups(1) As InvokeKinds
                  Groups(0) = INVOKE_FUNC Or INVOKE_PROPERTYGET Or _
                  INVOKE_PROPERTYPUT Or INVOKE_PROPERTYPUTREF

                  ReDim aResults(0)
                  bFound = False
                  With TypeLibInfoFromFile(sTypelib)
                  .SearchDefault = tliStClasses Or tliStEvents
                  For Each SI In .GetMembersWithSubStringEx(sSymbol, Groups)
                  bFound = True
                  arr.AAdd_PostIncrement aResults, SI.Name
                  Next
                  End With
                  if bFound then
                  ReDim Preserve aResults(UBound(aResults) - 1)
                  end if
                  SearchTLIMethodsAndProperties = aResults
                  End Function


                  VBScript demo. The above code was included in my StdLib DLL in the Registry coclass.



                  Dim O, R
                  Set O = CreateObject("Std.Registry")
                  Set R = CreateObject("Std.Arrays")
                  WScript.Echo R.ShowStructure( O.SearchTLIMethodsAndProperties( "MSSCRIPT.OCX",""))


                  Output from the demo (script was run in SciTE).



                  >cscript "C:foofoo.vbs"
                  {Add,AddCode,AddObject,AllowUI,Clear,CodeObject,Column,Count,Description,Error,Eval,ExecuteStatement,HasReturnValue,HelpContext,HelpFile,Item,Language,Line,Modules,Name,NumArgs,Number,Procedures,Reset,Run,SitehWnd,Source,State,Text,Timeout,UseSafeSubset}
                  >Exit code: 0


                  Finally, the VBA code. A cell has a symbol in it and this routine finds it or returns an error string.



                  Public Function LookupSymbol(sSym As String) As String
                  Dim aRes As Variant
                  aRes = reg.SearchTLIMethodsAndProperties("MSSCRIPT.OCX", sSym)
                  Dim i As Integer
                  LookupSymbol = "!!NotFound!!"
                  For i = 0 To UBound(aRes)
                  If LCase$(aRes(i)) = LCase$(sSym) Then
                  LookupSymbol = sSym
                  Exit For
                  End If
                  Next
                  End Function


                  Looking back on it now, I think I might pass in the path to the DLL/OCX as the first parameter.






                  share|improve this answer


























                    1












                    1








                    1







                    After Googling around not quite finding what I wanted, I remembered the Edanmo site which got me thinking about TLBINF32.DLL, downloading Microsoft's TLBINF32.CHM and reading up on GetMembersWithSubStringEx. Below is the implementation of it (done in VB6 with a reference to TLBINF32.DLL), some demo VBScript and output, and the wrapping of that functionality in some VBA.



                    Public Function SearchTLIMethodsAndProperties(sTypelib As Variant, sSymbol As Variant) As Variant
                    Dim SI As SearchItem
                    Dim aResults As Variant
                    Dim bFound as boolean
                    Dim Groups(1) As InvokeKinds
                    Groups(0) = INVOKE_FUNC Or INVOKE_PROPERTYGET Or _
                    INVOKE_PROPERTYPUT Or INVOKE_PROPERTYPUTREF

                    ReDim aResults(0)
                    bFound = False
                    With TypeLibInfoFromFile(sTypelib)
                    .SearchDefault = tliStClasses Or tliStEvents
                    For Each SI In .GetMembersWithSubStringEx(sSymbol, Groups)
                    bFound = True
                    arr.AAdd_PostIncrement aResults, SI.Name
                    Next
                    End With
                    if bFound then
                    ReDim Preserve aResults(UBound(aResults) - 1)
                    end if
                    SearchTLIMethodsAndProperties = aResults
                    End Function


                    VBScript demo. The above code was included in my StdLib DLL in the Registry coclass.



                    Dim O, R
                    Set O = CreateObject("Std.Registry")
                    Set R = CreateObject("Std.Arrays")
                    WScript.Echo R.ShowStructure( O.SearchTLIMethodsAndProperties( "MSSCRIPT.OCX",""))


                    Output from the demo (script was run in SciTE).



                    >cscript "C:foofoo.vbs"
                    {Add,AddCode,AddObject,AllowUI,Clear,CodeObject,Column,Count,Description,Error,Eval,ExecuteStatement,HasReturnValue,HelpContext,HelpFile,Item,Language,Line,Modules,Name,NumArgs,Number,Procedures,Reset,Run,SitehWnd,Source,State,Text,Timeout,UseSafeSubset}
                    >Exit code: 0


                    Finally, the VBA code. A cell has a symbol in it and this routine finds it or returns an error string.



                    Public Function LookupSymbol(sSym As String) As String
                    Dim aRes As Variant
                    aRes = reg.SearchTLIMethodsAndProperties("MSSCRIPT.OCX", sSym)
                    Dim i As Integer
                    LookupSymbol = "!!NotFound!!"
                    For i = 0 To UBound(aRes)
                    If LCase$(aRes(i)) = LCase$(sSym) Then
                    LookupSymbol = sSym
                    Exit For
                    End If
                    Next
                    End Function


                    Looking back on it now, I think I might pass in the path to the DLL/OCX as the first parameter.






                    share|improve this answer













                    After Googling around not quite finding what I wanted, I remembered the Edanmo site which got me thinking about TLBINF32.DLL, downloading Microsoft's TLBINF32.CHM and reading up on GetMembersWithSubStringEx. Below is the implementation of it (done in VB6 with a reference to TLBINF32.DLL), some demo VBScript and output, and the wrapping of that functionality in some VBA.



                    Public Function SearchTLIMethodsAndProperties(sTypelib As Variant, sSymbol As Variant) As Variant
                    Dim SI As SearchItem
                    Dim aResults As Variant
                    Dim bFound as boolean
                    Dim Groups(1) As InvokeKinds
                    Groups(0) = INVOKE_FUNC Or INVOKE_PROPERTYGET Or _
                    INVOKE_PROPERTYPUT Or INVOKE_PROPERTYPUTREF

                    ReDim aResults(0)
                    bFound = False
                    With TypeLibInfoFromFile(sTypelib)
                    .SearchDefault = tliStClasses Or tliStEvents
                    For Each SI In .GetMembersWithSubStringEx(sSymbol, Groups)
                    bFound = True
                    arr.AAdd_PostIncrement aResults, SI.Name
                    Next
                    End With
                    if bFound then
                    ReDim Preserve aResults(UBound(aResults) - 1)
                    end if
                    SearchTLIMethodsAndProperties = aResults
                    End Function


                    VBScript demo. The above code was included in my StdLib DLL in the Registry coclass.



                    Dim O, R
                    Set O = CreateObject("Std.Registry")
                    Set R = CreateObject("Std.Arrays")
                    WScript.Echo R.ShowStructure( O.SearchTLIMethodsAndProperties( "MSSCRIPT.OCX",""))


                    Output from the demo (script was run in SciTE).



                    >cscript "C:foofoo.vbs"
                    {Add,AddCode,AddObject,AllowUI,Clear,CodeObject,Column,Count,Description,Error,Eval,ExecuteStatement,HasReturnValue,HelpContext,HelpFile,Item,Language,Line,Modules,Name,NumArgs,Number,Procedures,Reset,Run,SitehWnd,Source,State,Text,Timeout,UseSafeSubset}
                    >Exit code: 0


                    Finally, the VBA code. A cell has a symbol in it and this routine finds it or returns an error string.



                    Public Function LookupSymbol(sSym As String) As String
                    Dim aRes As Variant
                    aRes = reg.SearchTLIMethodsAndProperties("MSSCRIPT.OCX", sSym)
                    Dim i As Integer
                    LookupSymbol = "!!NotFound!!"
                    For i = 0 To UBound(aRes)
                    If LCase$(aRes(i)) = LCase$(sSym) Then
                    LookupSymbol = sSym
                    Exit For
                    End If
                    Next
                    End Function


                    Looking back on it now, I think I might pass in the path to the DLL/OCX as the first parameter.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered May 14 '09 at 2:33









                    bugmagnetbugmagnet

                    4,245645109




                    4,245645109

























                        0














                        I have used Microsofts interactive OLE/COM-Object viewer to find mehods and their parameters in ActiveX-DLLs. Maybe looking at the source code of the viewer will lead you in the right direction: MSDN OleView sample






                        share|improve this answer




























                          0














                          I have used Microsofts interactive OLE/COM-Object viewer to find mehods and their parameters in ActiveX-DLLs. Maybe looking at the source code of the viewer will lead you in the right direction: MSDN OleView sample






                          share|improve this answer


























                            0












                            0








                            0







                            I have used Microsofts interactive OLE/COM-Object viewer to find mehods and their parameters in ActiveX-DLLs. Maybe looking at the source code of the viewer will lead you in the right direction: MSDN OleView sample






                            share|improve this answer













                            I have used Microsofts interactive OLE/COM-Object viewer to find mehods and their parameters in ActiveX-DLLs. Maybe looking at the source code of the viewer will lead you in the right direction: MSDN OleView sample







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered May 13 '09 at 10:22









                            Stephan KellerStephan Keller

                            1,4781013




                            1,4781013























                                0














                                If you want to do it programmatically - I'm not aware of a simple way to do that. Anyway, if you really need to (and if your programming language is capable enough) - you can query the type library (refer to ITypeLib description somewhere at http://msdn.microsoft.com/en-us/library/ms221549.aspx).



                                Also, if you already have an IDispatch pointer - you might consider using its services to dynamically enumerate methods supported by the interface (refer to IDispatch description in MSDN).






                                share|improve this answer




























                                  0














                                  If you want to do it programmatically - I'm not aware of a simple way to do that. Anyway, if you really need to (and if your programming language is capable enough) - you can query the type library (refer to ITypeLib description somewhere at http://msdn.microsoft.com/en-us/library/ms221549.aspx).



                                  Also, if you already have an IDispatch pointer - you might consider using its services to dynamically enumerate methods supported by the interface (refer to IDispatch description in MSDN).






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    If you want to do it programmatically - I'm not aware of a simple way to do that. Anyway, if you really need to (and if your programming language is capable enough) - you can query the type library (refer to ITypeLib description somewhere at http://msdn.microsoft.com/en-us/library/ms221549.aspx).



                                    Also, if you already have an IDispatch pointer - you might consider using its services to dynamically enumerate methods supported by the interface (refer to IDispatch description in MSDN).






                                    share|improve this answer













                                    If you want to do it programmatically - I'm not aware of a simple way to do that. Anyway, if you really need to (and if your programming language is capable enough) - you can query the type library (refer to ITypeLib description somewhere at http://msdn.microsoft.com/en-us/library/ms221549.aspx).



                                    Also, if you already have an IDispatch pointer - you might consider using its services to dynamically enumerate methods supported by the interface (refer to IDispatch description in MSDN).







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered May 14 '09 at 0:02









                                    AndreyAndrey

                                    3,19511527




                                    3,19511527






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f856309%2fhow-do-i-search-an-activex-com-object-for-a-method%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Create new schema in PostgreSQL using DBeaver

                                        Deepest pit of an array with Javascript: test on Codility

                                        Costa Masnaga