Results 1 to 8 of 8

Thread: [RESOLVED] Can't add referrence to the specified file

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    341

    Resolved [RESOLVED] Can't add referrence to the specified file

    During practice in VB6, it is a usual circumstance where we will referrence to a particular dll, tlb or ocx files... However, sometimes when I try to referrence to one, or any one that I've never used or learnt before, the IDE will generate an error message:

    "can't add referrence to the specified file" ...
    So my first question is:

    what dll can be referrenced in vb6 and what cannot? why?
    and second is:

    What is the difference between dll and tlb files?
    third:

    If my vb6 can't load it, is there another way to view the functions in that dll, as I understand that dll file stores a bunch of functions that are shared by applications

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,623

    Re: Can't add referrence to the specified file

    vb6 works with com.

    Any com dll should be usable by vb6, you can actually make .NET dll's com visible as well (if you have the source project) and if you do this they can also be used by VB6.

    Standard .Net dll's cannot be used by vb6 as they are based on a different technology.

    A tlb or Type Library file is just like a definition file for a dll. It describes all the public events and methods so they can be registered and used.

    Type Library information is stored in the registry for com dll's so Windows knows how to use them.

    If your dll is a .Net dll then you can view it by adding it to a .Net project, but it will not add to your VB6 project
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,443

    Re: Can't add referrence to the specified file

    There is a lot more contained in a type library than ever gets written to the registry, which is just a typelib ID that can be looked up to locate the file contaning the actual "registered" type library. Many ActiveX/OLE DLLs (including OCXs, which merely use an alternative naming convention) have the typelib embedded as a data section, while others make use of a separate TLB file.

    Class IDs also get registered, usually to point to the related typelib ID and to define ProgIDs, control siting requirements for control classes, interface versioning, and instantiation information.


    A COM DLL doesn't need to have typelib information at all, and indeed most COM DLLs written in C++ (including a large number of Windows-supplied DLLs) do not. Programs using them are normally written in C++ and are expected to use header files instead of typelibs. Since VB6 does not "work with COM" these DLLs can be very hard to use in a VB6 program unless somebody creates an external helper typelib file for them.


    So-called "standard" DLLs usually have no typelib information, and have no classes defined in them either. However they still can have typelibs, either embedded or as separate files.


    It gets confusing because people often conflate terminology such as COM, OLE, and ActiveX. Microsoft doesn't do a lot to help either, often interchanging these terms.


    If my vb6 can't load it, is there another way to view the functions in that dll, as I understand that dll file stores a bunch of functions that are shared by applications
    In such cases you need to look at the DLL's header (.H) and/or .IDL files, which contain definitions of exported items.
    Last edited by dilettante; Dec 19th, 2014 at 08:50 AM.

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,930

    Re: Can't add referrence to the specified file

    Quote Originally Posted by dilettante View Post
    In such cases you need to look at the DLL's header (.H) and/or .IDL files, which contain definitions of exported items.
    Or - if the OPs interest is only in determining, whether a Dll is a COM-Dll or a "Flat-Dll" -
    the Depends.exe tool (commonly known under its "friendly name" as "DependencyWalker")
    can help to explore at least the names of the exported Functions within a Dll - and COM-Dlls
    have (usually) only 4 exports:

    DllRegisterServer
    DllUnRegisterServer
    DllGetClassObject
    DllCanUnloadNow

    Olaf

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    341

    Re: Can't add referrence to the specified file

    Quote Originally Posted by NeedSomeAnswers View Post
    If your dll is a .Net dll then you can view it by adding it to a .Net project, but it will not add to your VB6 project

    I haven't formally worked with .Net yet. But I definitely will try to learn it in the future.

    Excel VBA - [Create Excel Toolbar Add-In]
    Saw in your signature - the EXCEL VBA part. Actually I started with EXCEL VBA and then VB6. After finding out the power of VB6 I almost stopped VBA learning. Anyway, aren't they the same?
    Last edited by bPrice; Dec 20th, 2014 at 12:53 AM.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    341

    Re: Can't add referrence to the specified file

    Quote Originally Posted by dilettante View Post

    A COM DLL doesn't need to have typelib information at all, and indeed most COM DLLs written in C++ (including a large number of Windows-supplied DLLs) do not. Programs using them are normally written in C++ and are expected to use header files instead of typelibs. Since VB6 does not "work with COM" these DLLs can be very hard to use in a VB6 program unless somebody creates an external helper typelib file for them.

    Thorough explantion. Should I learn some C++ by the way? I read some basic tutorial on C++ but never deepened the knowledge.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    341

    Re: Can't add referrence to the specified file

    Quote Originally Posted by Schmidt View Post

    the Depends.exe tool (commonly known under its "friendly name" as "DependencyWalker")
    can help to explore at least the names of the exported Functions within a Dll - and COM-Dlls
    have (usually) only 4 exports:

    DllRegisterServer
    DllUnRegisterServer
    DllGetClassObject
    DllCanUnloadNow

    Olaf
    I will try this someday

    In case anyone else might be interested in the topic, here is the click-to-download link for Dependency Walker.


    Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all dependent modules.
    Last edited by bPrice; Dec 20th, 2014 at 01:06 AM.

  8. #8
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,119

    Re: Can't add referrence to the specified file

    Quote Originally Posted by bPrice View Post
    .... Actually I started with EXCEL VBA and then VB6. After finding out the power of VB6 I almost stopped VBA learning. Anyway, aren't they the same?
    No, not really. The transition from VB3 to VB4 is where VB started sharing the same language core with VBA, so the Visual Basic "language" is the same for VB6 and VBA, but the controls and classes that support the various flavors of the language are different. VBA is tailored for applications, so that is why you would usually distinguish EXEL VBA vs Word VBA, etc.
    The only time I even attempted doing anything with VBA was at work when I didn't have VB available. Imagine my disappointment when I found that you can't draw using Lines, Circles, etc.. on Forms or Pictureboxes in VBA the way you can in VB. It was enough of a deterrent, that I ended up going back to using VB3 at work for awhile, since I didn't have to install VB3 to use it (as long as I didn't use any of the third party controls). Anyway, that was 8 years ago or so, and I've never really given VBA another try.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width