How To Export Functions Present in a ActiveX Dll

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JMurugesh
    New Member
    • Nov 2007
    • 13

    How To Export Functions Present in a ActiveX Dll

    How To Export Functions Present in a ActiveX Dll?

    So that i can use that vb dlll from any application.... .....
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    You cannot Export Functions, It is embedded/hidden in the DLL.
    Add that .dll Reference to your VB Project.
    Declare Variables of the .dll objects. and use the Functions..


    Regards
    Veena

    Comment

    • AHMEDYO
      New Member
      • Nov 2007
      • 112

      #3
      hi

      VC++ only can do that, u can create dll and use it as windows API, in VB6 u just can create COM Classes, but u can create new class and set instancing property to GlobalMultiuse and then add this dll to ur project rerefnce and call function direct as visual basic standard libraries

      Comment

      • JMurugesh
        New Member
        • Nov 2007
        • 13

        #4
        Originally posted by AHMEDYO
        hi

        VC++ only can do that, u can create dll and use it as windows API, in VB6 u just can create COM Classes, but u can create new class and set instancing property to GlobalMultiuse and then add this dll to ur project rerefnce and call function direct as visual basic standard libraries
        Hi
        I am accepting , but once if i create a dll using vc++6.0 with export options...
        Can i use that dll dynamically in vb6.0? If so tell me how it can be done?

        waiting for reply...

        Comment

        • JMurugesh
          New Member
          • Nov 2007
          • 13

          #5
          Originally posted by QVeen72
          Hi,

          You cannot Export Functions, It is embedded/hidden in the DLL.
          Add that .dll Reference to your VB Project.
          Declare Variables of the .dll objects. and use the Functions..


          Regards
          Veena
          Hi
          I want to use that dll dynamically..
          Is there any functions similar to CreateObject(us ed in creating object for activex dll) . For me the dll is Win32 dll.........

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            Yes DLL files compiled in most of the languages can be called from any other languages.

            Comment

            • AHMEDYO
              New Member
              • Nov 2007
              • 112

              #7
              look man u have two types of Dlls, COM and u can use it by CreateObject method and the other type just u can imagine it as External Module have public function as Windows API, this type u cant export from VB6, if u can work with VC++ its simple to do that , by Declare ur functions with __declspec(dlle xport) keywords and then declare this function then in ur vb6 project

              example VC++ Dll File Name "MyDll.dll"

              DWORD __declspec(dlle xport) TestFunction(LP STR Data);

              then in VB6

              Declare Function TestFunction lib "MyDll.dll" (byval Str as String)as Long

              Private sub Form_Load()
              Dim x as long
              x=TestFunction( "Text")
              End Sub

              and u can use another way and ignore that u declare it as above

              u can use dll with ur code by LoadLibrary() & GetProcAddress API Functions but it will let u to work more to call any function and u will care about stack

              Comment

              • JMurugesh
                New Member
                • Nov 2007
                • 13

                #8
                Declare Function TestFunction lib "MyDll.dll" (byval Str as String)as Long

                The method above is static linking , but i need to link dynamically...

                It can be done through LoadLibrary and GetProcAddres and some memory related API such as CopyMemory, Heap...

                But What i want to know is... Is there any other easy method available in VB6 to do this work?

                Comment

                • AHMEDYO
                  New Member
                  • Nov 2007
                  • 112

                  #9
                  Originally posted by JMurugesh
                  Declare Function TestFunction lib "MyDll.dll" (byval Str as String)as Long

                  The method above is static linking , but i need to link dynamically...

                  It can be done through LoadLibrary and GetProcAddres and some memory related API such as CopyMemory, Heap...

                  But What i want to know is... Is there any other easy method available in VB6 to do this work?
                  Hi..

                  i think there is no other way from VB to do that , and i think only visual C++ support simple method than visual basic because you can define functions take list of arguments with VC++ with "typedef" keyword & ... 3 dots to define arguments list, you can use API call only as LoadLibrary and GetProcAddress & "CallWindowspro c" from VB to call your dll functions

                  but visual basic have one thing that you can care about, CallByName Function

                  Code:
                  CallByName(Object as Object,Procname as String,Calltype as VbCallType,Args() as Variant)
                  but you must call function from object variable, you must define your functions within COM Class, thats mean you will static link your Dll or you can use createobject() function to dynamically create your object and dynamically call object functions by CallByName

                  Good Luck

                  Comment

                  • JMurugesh
                    New Member
                    • Nov 2007
                    • 13

                    #10
                    Originally posted by AHMEDYO
                    Hi..

                    i think there is no other way from VB to do that , and i think only visual C++ support simple method than visual basic because you can define functions take list of arguments with VC++ with "typedef" keyword & ... 3 dots to define arguments list, you can use API call only as LoadLibrary and GetProcAddress & "CallWindowspro c" from VB to call your dll functions

                    but visual basic have one thing that you can care about, CallByName Function

                    Code:
                    CallByName(Object as Object,Procname as String,Calltype as VbCallType,Args() as Variant)
                    but you must call function from object variable, you must define your functions within COM Class, thats mean you will static link your Dll or you can use createobject() function to dynamically create your object and dynamically call object functions by CallByName

                    Good Luck
                    Understand my problem clearly... I am having several application both in vb and vc... and i want to use a single dll which will get shared by all applications both vb and vc........

                    Comment

                    • AHMEDYO
                      New Member
                      • Nov 2007
                      • 112

                      #11
                      Originally posted by JMurugesh
                      Understand my problem clearly... I am having several application both in vb and vc... and i want to use a single dll which will get shared by all applications both vb and vc........
                      i understand your problem man, if you will create COM class you can call your function dynamically from VB by CallByName and you can call it dynamically too from VC++ by allocation your function address from function address pointers table using COM API functions, but its not just one function call as VB CallByname function

                      this link will help you with VC++

                      Comment

                      • JMurugesh
                        New Member
                        • Nov 2007
                        • 13

                        #12
                        Originally posted by AHMEDYO
                        i understand your problem man, if you will create COM class you can call your function dynamically from VB by CallByName and you can call it dynamically too from VC++ by allocation your function address from function address pointers table using COM API functions, but its not just one function call as VB CallByname function

                        this link will help you with VC++

                        http://msdn2.microsoft.com/en-us/library/ms680586.aspx

                        Do you have any samples? If so tell me... Thanks in Advance..

                        Comment

                        • JMurugesh
                          New Member
                          • Nov 2007
                          • 13

                          #13
                          Can we use CoGetClassObjec t to create the Object for activeX dll.

                          Comment

                          • JMurugesh
                            New Member
                            • Nov 2007
                            • 13

                            #14
                            Originally posted by QVeen72
                            Hi,

                            You cannot Export Functions, It is embedded/hidden in the DLL.
                            Add that .dll Reference to your VB Project.
                            Declare Variables of the .dll objects. and use the Functions..


                            Regards
                            Veena
                            Can we use CoGetClassObjec t to get the object of the class?

                            Comment

                            • QVeen72
                              Recognized Expert Top Contributor
                              • Oct 2006
                              • 1445

                              #15
                              Hi,

                              After adding that dll in your new VB Project,
                              Use "Object Browser" to view all the Properties/Classes /Procedures of that dll..

                              Regards
                              Veena

                              Comment

                              Working...