Announcement

Collapse
No announcement yet.

Has anyone gotten a compiled Dll to work with VB, VBA or VBSCRIPT?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    no jc, the example doesnt work for me. Is there a step there we are possibly missing?

    After doing a regsrv32 I have nothing in the registry, no class or guids. I must be doing something wrong, I can see power basic releasing this without testing against vb or vbscript.
    Sr. Software Development Engineer and Sr. Information Security Analyst,
    CEH, Digital Forensic Examiner

    Comment


    • #22
      James,
      Yes you are right.
      This brings new info..

      Not sure how can use:
      Set Foo = New MyObject.MyClass

      Because everyone will use this syntax.
      And then there is .NET, if it ain't loaded by that one.. i don't know it anymore..
      See the other topic and the image.
      hellobasic

      Comment


      • #23
        I think Thomas has another issue anyway.
        On the other topic there is a class in a zipfile.
        You may give it a shot.
        hellobasic

        Comment


        • #24
          David, Thomas

          from my previous post:

          Code:
          The easiest method of embedding a typlib in your dll is with a resource file.
          
          Contents of YourDll.Rc
          1 TYPELIB "YourDll.Tlb"
          
          Load and compile the rc file to a pbr and use in your source.
          
          #RESOURCE "YourDll.Pbr"
          All regsvr32.exe does is tell where the dll is and will register it whether or not the tlb is embedded or not.

          James

          Comment


          • #25
            James Fuller,

            'You are here!'

            Thank you, I have successfully run your example.

            David

            Comment


            • #26
              strange stuff

              Still, I believe there is an issue with IDispatch as an parameter in a method.

              I can't seem to get any ActiveX control to work that requires an IDispatch as a parameter.
              So here we are, this is the end.
              But all that dies, is born again.
              - From The Ashes (In This Moment)

              Comment


              • #27
                I am not satisfied either.
                maybe PB has an example?
                hellobasic

                Comment


                • #28
                  Thomas
                  I agree that if properly registered the DLL can be anywhere but you said you couldn't find a succesful registration. Note the comments for error 48 above.
                  It can get complicated, I have a program (done it in both PB and VB) which requires two ActiveX DLL's created in VB ( by another party), the first is the only one that can be registered and its location doesn't matter, but it calls the second which is not registerable. For both PB and VB the second needs to be in a normal DLL location ie program folder.
                  To be more specific I think you have naming confusion. Don't have 9 yet but try using the same unique name for the DLL and the class so that regsvr32 can find the automatically inserted DllSelfRegister function. Remember it will be in the registry under the class name not the DLL name so something more descriptive than "MyClass" might help.
                  John
                  Last edited by John Petty; 26 Aug 2008, 09:32 AM.

                  Comment


                  • #29
                    John,

                    My primary problem is registration. I can get the dll to load in Excel and Word to view the type lib. This is not the issue. My Secondary problem is that all dll's that are created list the interfaces as notcreateable.
                    Sr. Software Development Engineer and Sr. Information Security Analyst,
                    CEH, Digital Forensic Examiner

                    Comment


                    • #30
                      Disregard, this is the same James has posted above.
                      Last edited by Knuth Konrad; 26 Aug 2008, 11:29 AM.

                      Comment


                      • #31
                        Thomas
                        The registration process is what I am on about. The DLL needs a function called DLLSelfRegister and/or possibly two others called something like DLLserverregister and DLLserverunregister (forget the exact names) which it seems are put in by the compiler when you define it as a COM. If registration fails then normally VB can't find it. Until you get past that then your second problem is moot.
                        As I sais don't have 9 yet but if you give the class a name like ThomasProblem and attach the compiled DLL to a post then I am happy to test for you.
                        John

                        Comment


                        • #32
                          regsvr32.exe appears to be a gui process and outputs to a msgbox that registration either succeeded or failed. Is its output stating that it succeeded but you are not finding the correct registry entries in spite of that?

                          Also, I have created COM Dll servers using C where I registered the component in the registry but did not create a typelib. These I can call using PowerBASIC by using Direct Access (working on that sort of thing right now). I may be wrong about this, but by registering the type lib info that allows for connecting through IDispatch/Automation.

                          As others have said, what regsvr32 does is call DllRegisterServer in the Dll, which is an exported function. I believe this is implemented within the compiler so we don't have to do it in PB ourselves. If one is using C/C++ one must write that code oneself, and its a rather dreary job.
                          Last edited by Fred Harris; 26 Aug 2008, 11:58 AM.
                          Fred
                          "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                          Comment


                          • #33
                            Fred
                            Command line with message boxes for result
                            Possible message boxes can be found here http://support.microsoft.com/kb/249873
                            John

                            Comment


                            • #34
                              Why noncreatable?

                              Hi James,

                              As far as I can see, the "problem" is that the type library built by PB is specifying the interface/class as noncreatable. That being the case, you will only be able to "Implement" the interface in an object module in VB - i.e.
                              Code:
                              Implements IItem.MYCLASS
                              (or use CreateObject with it).

                              However, if you remove the noncreatable attribute from the type library manually and recompile it, then include it in the DLL (using PBTYP, for example), then VB will allow:
                              Code:
                              Dim cTest As IItem.MYCLASS
                              Set cTest = New IItem.MYCLASS
                              I'm not saying that's a nice solution (or a solution at all), and I'm not saying the resulting object will necessarily always work as advertised, but using the sample code Steve Rossell recently posted in this forum for a simple class, it appears to work perfectly well.

                              So I guess the question really is, why is PB setting the "noncreatable" attribute in the first place? From what I can gather, this is part of the instancing settings for COM, and there appears to be no way to set this from within the PB Class definition.

                              Perhaps those with greater knowledge and/or understanding can explain the reasoning behind this?

                              Regards,

                              Pete.

                              Comment


                              • #35
                                Cool.
                                Your last code is how it should be.
                                Not sure how to deal with the tlb data.
                                Guess we must set our hopes to PB making a modification for this.
                                (please )
                                hellobasic

                                Comment


                                • #36
                                  Peter,

                                  First, how did you find it's non-creatable and second, how do you manually change it in the TypeLib ? What tools do you use ?

                                  Cheers

                                  Steven
                                  So here we are, this is the end.
                                  But all that dies, is born again.
                                  - From The Ashes (In This Moment)

                                  Comment


                                  • #37
                                    Originally posted by Edwin Knoppert View Post
                                    Guess we must set our hopes to PB making a modification for this.
                                    (please )
                                    I second that.

                                    Set x = New <class> is the most common way objects are instanced in VB. It would be nice if we could support that with PB.

                                    Comment


                                    • #38
                                      Hi Steven,

                                      The interface is listed as noncreatable by OLE View - a tool that is provided with Visual Studio 6. Thomas actually mentioned this in the first post in the thread.

                                      OLE View also lets you see the decompiled IDL (Interface Definition (or Description) Language) for the type library and save it out as a text file. From there, I just removed the "noncreatable" attribute and saved the file, recompiled it to a TLB with MIDL (also supplied with Visual Studio as part of VC++) and attached it to the DLL with PBTYP.

                                      Regards,

                                      Pete.
                                      Last edited by Peter Jinks; 27 Aug 2008, 08:22 AM. Reason: Pedantry

                                      Comment


                                      • #39
                                        Peter,

                                        Great ! I check this out.

                                        Steven
                                        So here we are, this is the end.
                                        But all that dies, is born again.
                                        - From The Ashes (In This Moment)

                                        Comment


                                        • #40
                                          Bless you guys . I thought it was me and it was driving me bananas. I will give it a try and see if I can get it to work..

                                          Thanks All!!!

                                          Has anyone sent an email to support to fix this?
                                          Sr. Software Development Engineer and Sr. Information Security Analyst,
                                          CEH, Digital Forensic Examiner

                                          Comment

                                          Working...
                                          X