Results 1 to 15 of 15

Thread: windows api (winU.tlb),how to add api SysAllocString as long?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,940

    windows api (winU.tlb),how to add api SysAllocString as long?

    Code:
    Function SysAllocString(sz As String) As String
        Win.OleAuto ???
        Allocates and returns a BSTR for a given LPSTR
    how to change return long?
    Function SysAllocString(sz As String) As as long

    WinTlbU.zip
    http://www.mvps.org/vb/hardcore/code/WinTlbU.zip
    Bruce McKinney ? Windows Unicode API

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,940

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    Function SysAllocStringPtrPtr(pStr As Long) As Long
    Win32Api.tlb can't support string arg

    Private Declare Function newstrAPI Lib "oleaut32.dll" Alias "SysAllocString" (ByVal pOlechar As Long) As Long 'good

    Private Declare Function newstrapi2 Lib "oleaut32.dll" Alias "SysAllocString" (ByVal FromStr As String) As Long
    'The Chinese characters became garbled
    ========================
    NEED PUT THIS API TO TLB

    Private Declare Function newstrapi2 Lib "oleaut32.dll" Alias "SysAllocString" ( FromStr As String) As Long
    IN vb6 api, string will change to ansi
    in tlb,string is unicode
    Last edited by xiaoyao; May 23rd, 2024 at 11:07 AM.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,940

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    how to make tlb by api,like

    Actual UDTs that mirror what we're creating in the dynamic typelib.

    https://www.vbforums.com/showthread....08#post5610008
    Code:
        moCreateTLB.SetGuid uGuid
        moCreateTLB.SetVersion iMajorVersion, iMinorVersion
        If TlbName = "" Then TlbName = "ABC_UserDataType"
        moCreateTLB.SetName TlbName
        
        ' Write our TypeLib to disk (in our App.Path folder).
        moCreateTLB.SaveAllChanges
    how to do ?
    ICreateTypeInfo.AddFuncDesc(oleaut32.dll,SysAllocString,"arg1 as string",return as long)

  4. #4
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    add it to the source and recompile.

    No idea why though; if you define it locally it will get priority over the typelib.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,940

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    Quote Originally Posted by fafalone View Post
    add it to the source and recompile.

    No idea why though; if you define it locally it will get priority over the typelib.
    Can you develop a tool that automatically converts VB6 API declarations to TLB?

    ICreateTypeInfo can make user data type save as tlb file
    ICreateTypeInfo how to add api declaration to save as tlb file,without vc++,MIDL.exe Compiler?
    Last edited by xiaoyao; May 23rd, 2024 at 05:44 PM.

  6. #6
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    I or most other intermediate to advanced programmers *could* write an automatic conversion tool, but it would take more time than I care to spend my limited hobby time on.

    Advanced VB 6.0 - Power Techniques for Everyday Programming came with a typelib editor that uses ICreateTypeInfo, track that down, but again, why? The winu source is all set up for a simple midl compile, and midl comes with VS6 or any newer SDK.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,940

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    Quote Originally Posted by fafalone View Post
    I or most other intermediate to advanced programmers *could* write an automatic conversion tool, but it would take more time than I care to spend my limited hobby time on.

    Advanced VB 6.0 - Power Techniques for Everyday Programming came with a typelib editor that uses ICreateTypeInfo, track that down, but again, why? The winu source is all set up for a simple midl compile, and midl comes with VS6 or any newer SDK.
    Everyday Programming came with a typelib editor that uses ICreateTypeInfo
    how to download?

    a tool that automatically converts VB6 API declarations to TLB

    All you need is a simple conversion template, just like TWINBASIC translating into different languages, the simple solution is to directly find the replacement word and replace it with another language.
    Mainly BYVAL,BYREF, but also STRING, array and so on how to represent in IDL

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    If it's so simple you make it. Make it parse twinBASIC extensions too (DeclareWide, [TypeHint()], and overloads) and then you'd be able to export the largest VB-compatible API set ever compiled to a VB6-compatible TLB. WinU.tlb covers so few interfaces and APIs it's a rounding error compared to WDL.

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,940

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    tlb?Is there a distinction between 32-bit and 64-bit?Or is it just the data type?
    It would be handy if you could use twinbasic to compile API declarations directly into Tapi

    ?export api?
    Private Declare Function FindWindow1 Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    I hope you can give him this advice.

    Microsoft c# . Net8 AOT compiles standalone DLLs in this way.

  10. #10
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    TLBs have to be compiled separately for 32bit and 64bit yes.

    And you're still not answering the 'why' for all these odd questions. What possible value is there in making a DLL that exports the API definitions vs just copying the declarations themselves? Because then in VB6 you'd have to Declare Function FindWindow Lib "myDllThatExportsAPIs" Alias "FindWindow1" (ByVal lpClassName....

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,940

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    use midl.exe or vc++ make tlb?This is complex, requires a huge installation of tools, and can generate a lot of errors.

    Twinbasic, if it can generate TLB files by itself.
    It will be more convenient to make an export TLB function for the API declaration
    At first I needed the TLB file, mainly because it doesn't convert the parameter string to ANSI format.

    vb6 api Declare that it will actually be called through the dllcallfunction.

    Of type TLB. api. Maybe he didn't take this route.So the string encoding is not changed.

  12. #12
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    If you use Long/StrPtr, it won't change the format to ANSI.

    tB has DeclareWide, so you can use String without ANSI conversions right in the project.

    Exporting TLBs is planned, but not for v1.0, so very unlikely to happen this year.

  13. #13
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,628

    Lightbulb Re: windows api (winU.tlb),how to add api SysAllocString as long?

    Quote Originally Posted by xiaoyao View Post
    ?export api?
    Private Declare Function FindWindow1 Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    I hope you can give him this advice.
    No ANSI conversion required. Surely you should have already known this by now:

    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowW" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,940

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    yes ,use strptr("aabcc123"),but i like use
    findwindow("aabb123")
    i don't like findwindow(str("abc123")? or findwindow(strconv("abc123",vbFromUnicode))

  15. #15
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: windows api (winU.tlb),how to add api SysAllocString as long?

    So add APIs to winu or oleexp if you can't use the ANSI version.

    Or just use tB with DeclareWide. WinDevLib covers thousands of APIs with that exact pattern for A/W APIs:

    Code:
    Public Declare PtrSafe Function FindWindowA Lib "user32" (ByVal Class As String, ByVal Title As String) As LongPtr
    Public Declare PtrSafe Function FindWindowW Lib "user32" (ByVal Class As LongPtr, ByVal Title As LongPtr) As LongPtr
    Public DeclareWide PtrSafe Function FindWindow Lib "user32" Alias "FindWindowW" (ByVal Class As String, ByVal Title As String) As LongPtr
    + 1,157 more W Aliases with String.

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