Results 1 to 12 of 12

Thread: how to make tlb by vb6 for Declare windows api

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    how to make tlb by vb6 for Declare windows api

    The exe that refers to tlb, the import function adds GetMem8, and there is no DllFunctionCall, so the function call of GetMem4 will be quite fast (because the function of Declare first calls the DllFunctionCall function, and then the GetMem4 function is called by DllFunctionCall), and the reference to tlb saves Lost this intermediate link

  2. #2
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: how to make tlb by vb6 for Declare windows api

    If you're looking for a .tlb with GetMem8 or 4, it's probably in one of the ones on VBSpeed, http://www.xbeat.net/vbspeed/i_Dope.htm

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: how to make tlb by vb6 for Declare windows api

    Compiled code does not use type libraries, type libraries are just a form of partially compiled symbol table information. TLB files and resources are really just source code used by compilers and other development tools such as IDEs.

    GetMem4() and friends are not part of the Windows API, they are entrypoints in VB runtime libraries.


    I'm not aware of any useful "cookbook" tutorials on manually writing the MIDL/ODL (IDL) to compile into standalone TLBs. Most people just study existing examples, supplementing that by decompiling existing TLB files using the OLEView tool or something similar for ideas on how to handle different things.

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: how to make tlb by vb6 for Declare windows api

    I remember Bruce McKinney providing "his" source-code for "his" WinApi-TLB in "Hardcore Visual Basic".
    I took that as a starting point and wrote my own TLB for the ODBC-dll, basically doing what dilettante described: Take an existing example, and try (and error) to change it to your needs.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: how to make tlb by vb6 for Declare windows api

    Some people make hundreds or thousands of APIs into a single TLB file.
    Is it possible to use other tools to delete a few of it?Or modify the parameter type for each item.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: how to make tlb by vb6 for Declare windows api

    Cdecl function can be packaged good TLB file, call the time will not cause memory leaks? The stack is unbalanced.

  7. #7
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: how to make tlb by vb6 for Declare windows api

    Quote Originally Posted by xiaoyao View Post
    Some people make hundreds or thousands of APIs into a single TLB file.
    Is it possible to use other tools to delete a few of it?Or modify the parameter type for each item.
    Why would you delete an entry? Whatever for?
    You only need a TLB during developement (a.k.a. you don't have to ship it with your app), and only those entries you actually use in your app get "compiled" into your app.
    There is no penalty for TLB-Entries you don't use (contrary to writing declares!)

    Modifying a parameter-type is easy if you know the syntax. Then just recompile.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  8. #8
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: how to make tlb by vb6 for Declare windows api

    I also noticed that the compiled exe will not run faster just because u have a tlb.
    my experience is that u will not notice much difference.
    the purpose of a TLB is that u dont need to add all those API in your module, the same with the countless structures/udt and const variables.

    speed is about thinking how memory works, what will be the fastest way for the memory to do something.
    and thats string and graphics, those 2 eat a lot of time. so better focus on learning more about optimization.
    and as many already posted, when compiled only the used parts will be added to the table, so it doesnt matter if the tlb is gigantic in size.

  9. #9
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: how to make tlb by vb6 for Declare windows api

    Agree with baka.

    another bottleneck is the algorithm itself.
    nested loops come to mind.
    or harddrive-access
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  10. #10
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: how to make tlb by vb6 for Declare windows api

    Quote Originally Posted by Zvoni View Post
    only those entries you actually use in your app get "compiled" into your app.
    There is no penalty for TLB-Entries you don't use (contrary to writing declares!)

    I'm sorry if I got it wrong. But do you mean if within the TLB there are 1000 declarations, and I only use 2, then the compiler will only take two declarations at the time of compilation?

    Interesting, I didn't know that.

  11. #11
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: how to make tlb by vb6 for Declare windows api

    Quote Originally Posted by Episcopal View Post
    I'm sorry if I got it wrong. But do you mean if within the TLB there are 1000 declarations, and I only use 2, then the compiler will only take two declarations at the time of compilation?

    Interesting, I didn't know that.

    https://classicvb.net/hardweb/mckinney2a.htm
    Scroll down to Chapter 2 - Page 46
    Maybe you don't believe that type library entries add no overhead to your programs except for the entries you use. Maybe you don't believe that type library entries add no overhead to your programs except for the entries you use.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: how to make tlb by vb6 for Declare windows api

    Quote Originally Posted by baka View Post
    I also noticed that the compiled exe will not run faster just because u have a tlb.
    my experience is that u will not notice much difference.
    Actually it will run faster, but unless you are making tons of calls as within a long running loop you won't notice any performance gain. So, just like anything.

    Type libraries don't even need to be registered unless you want to search the registry to locate them on disk. For example adding via the VB6 IDE References dialog. Once added to the Project there is no need for the TLB to be registered.

    Example that grabs ANSI data, then converts it to lower-case Unicode to find and count the different non-number "words" in it:

    Name:  sshot.png
Views: 601
Size:  3.6 KB

    Replace the text input file with a larger one to really see the performance.

    This makes use of a TLB to call entrypoints in a number of different libraries, but mainly in shlwapi.dll for parsing. it can probably be even faster if you replace the xxxW calls with xxxIA (case-insensitive ANSI) calls, only converting "words" to Unicode to display them at the end.
    Attached Files Attached Files

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