Results 1 to 18 of 18

Thread: Why doesn't the "__vbaCastObj" function work in Twin Basic?

  1. #1

    Thread Starter
    Fanatic Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    587

    Why doesn't the "__vbaCastObj" function work in Twin Basic?

    Why doesn't the "__vbaCastObj" function work in Twin Basic?
    After attempting to execute the vbaCastObj function, a fatal crash of the Twin Basic development environment occurs, why? Here is a sample code: https://www.vbforums.com/showthread....=1#post5499151

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,705

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    Does it crash when calling it from C/C++? I.e. does it need VB6 runtime being initialized before calling it?

    cheers,
    </wqw>

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

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    You should put in a feature request to add it to the list of supported runtime functions (currently: VarPtr, GetMem1, GetMem2, GetMem4, GetMem8, PutMem1, PutMem2, PutMem4, PutMem8, __vbaObjSet, __vbaObjSetAddRef, __vbaObjAddRef, __vbaCopyBytes, __vbaCopyBytesZero, __vbaRefVarAry, and __vbaAryMove.)

  4. #4

    Thread Starter
    Fanatic Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    587

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    Please submit such a request. If you can.
    However, even without the built-in function, it should work through the API in theory, but it doesn't work...

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,705

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    This is not how bug reports works. You cannot just tell someone else to file a bug report with Wayne to go fix something that is not working in some code of yours somewhere.

    Do your part of the drill and create a decent report incl. some failing code as minimal as possible but not too minimal to not be able to copy/paste it and reproduce the problem.

  6. #6

    Thread Starter
    Fanatic Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    587

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    wqweto, you yourself understood from my posts in the topic where this question was originally raised that I do not seek to use the vbaCastObj function, since there are alternatives. However, you prefer the option with the vbaCastObj function, so please submit a request for this function yourself.

  7. #7
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,890

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    What wqweto is saying, is that Faf and wqweto don't work for TwinBasic. They also don't work for you.

    When Faf. has been kind enough to raise an issue on github for YOU it is because they are kind enough to do so and because he is a professional and wants to see TB fix YOUR problems.

    Neither Wqweto nor Faf really want to be YOUR servant. It takes 5 mins to open a github account and another 10 mins to cut/paste the text from this thread into a github issue. You SHOULD do this, it would only be common courtesy to do this yourself otherwise I suggest you stop using TwinBasic and use good ol' VB6 instead.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  8. #8

    Thread Starter
    Fanatic Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    587

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    For me personally, there is no strong need for this feature, as I personally do not use it. However, if you take care of other people, for others, you could insist that this feature be added to the Twin Basic and you could take care of it yourself. Personally, I don't need it, but it can be useful for other people. For example, the use of this function can sometimes be found in some program codes on this forum. These are mostly posts from the user The Trick, but that's not all. I think Elroy also used this function somewhere in his codes. And many more have used this feature. VanGoghGaming, too, in my opinion.

    This function is used by you, dear participants of this forum. It's you, not me. Therefore, you should also make sure that this feature is added if you want to see it.

    P. S. That was pretty rude. They even ruined my appetite (I was just eating at that time). I don't consider anyone here to be my servants. But I have no desire to communicate with you anymore at all. Please don't write to me anymore.

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

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    Now that we got a dedicated tB forum on VBF here, I don't really see it as an inappropriate place to raise feature requests and bug reports... ideally they should go on GitHub in a more formal manner so it's easier for Wayne to track, but it's hardly a hanging offense. Really probably worse to report in multiple locations; I only put duplicates on GitHub when they really should be more formalized with minimal reproductions. I don't mind helping out with things like that with people like HackerVlad that are respectful of the fact it's a favor done whenever I have the free time and interest out of desire to help tB succeed.

    With msvbvm60 there's thousands of undocumented functions. tB is not a reverse engineering project aiming to replicate VB6 internals, and runtime functions are rarely meant to be called in isolation. If a call to msvbvm60.dll doesn't work, it's not a bug tB will address. HOWEVER, if a runtime function is in popular use for basic utility operations, tB may support it by adding its own internal implementation where the call is redirected to that internal code, where the functionality is replicated in a manner that works with tB and more importantly, will continue to work with 64bit code, with pointers appropriately rewritten as LongPtr.

    It depends exactly what kind of function it is and how widely it's used. I think vbaCastObj is a reasonable candidate for being added. It's not particularly widely used but it is a simple utility function not too deeply intertwined with the rest of the runtime that wouldn't be difficult to provide an implementation of. But that's my opinion, it's entirely up to Wayne as it's his project... I'm just a big fan that does some volunteer stuff around the edges like helping people, writing demo projects like I did for VB6, moderating posts, and writing documentation.

    A contrary example would be CreateIExprServer, the main call to initialize the VB runtime on a thread. Something like that could never be supported because it's linked to all sorts of undocumented internals that run an entirely different architecture. Code using it, mainly The trick's multithreading module, as brilliant and impressive as it is, simply can't and won't be supported. But in cases like this, it's almost always about a hack to add functionality to VB6 that has native support in tB and is easily replaced with something far simpler. For that module, there's no need for any hacks prior to calling CreateThread. tB is already thread safe and designed with multithreading in mind, so you can just drop the module and call that API directly.
    Last edited by fafalone; Jan 13th, 2025 at 11:14 PM.

  10. #10
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,890

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    Quote Originally Posted by HackerVlad View Post
    P. S. That was pretty rude. They even ruined my appetite (I was just eating at that time). I don't consider anyone here to be my servants.
    Not rude at all, just another simple courtesy pointing out that it is in fact, rather rude to tell people what to do when you could do it yourself.

    Quote Originally Posted by HackerVlad View Post
    Please don't write to me anymore.
    Once again you are telling someone what to do, perhaps it is a language problem and we can forgive that but please note that I will always respond to try to encourage courtesy and the correct way of doing things. Whether you choose to act on them or not, that is up to you.

    You don't need to respond to me if you don't want to chat. I'm happy with that. Good luck getting people to help you.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  11. #11

    Thread Starter
    Fanatic Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    587

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    fafalone, thank you more. However, I don't understand why calling any functions (I'm talking about __vbaCastObj in particular) doesn't work from the library. msvbvm60.dll but does it work out of all the other DLL's in the system? Why can't you just declare it, and why isn't the function running successfully?

    I also wanted to ask if it is possible to use the OLE_HANDLE pointer instead of the LongPtr in the 64-bit version? I just came up with this idea, but I've never tried it yet.

    I didn't find anything about the CreateIExprServer function on the Internet, neither in Google nor in Yandex, there are no results.

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

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    It's possible the implementation relies on some other aspect of the runtime being initialized, rather than being completely isolated like some of the others.

    OLE_HANDLE still maps to a 4-byte Long in 64bit, so no, it's not a substitute for LongPtr.

    And sorry I was going from memory and got the name wrong, it's CreateIExprSrvObj.

  13. #13

    Thread Starter
    Fanatic Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    587

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    fafalone, Thank you very much for your help.

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

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    Looks like Wayne has added __vbaCastObj to the set of msvbvm60.dll functions supported via redirect to internal implementation as of Beta 648.

    added: redirection support for __vbaCastObj in MSVBVM60.DLL to internal implementation [ HackerVlad, vbforums ]

    For 64bit support, presumably you'd modify your declare to

    Private Declare PtrSafe Function vbaCastObj Lib "msvbvm60" _
    Alias "__vbaCastObj" ( _
    ByRef cObj As Any, _
    ByRef pIID As Any) As LongPtr


    though for WinDevLib I'm going to use this signature:

    Code:
    Public Declare PtrSafe Function vbaCastObj Lib "msvbvm60.dll" Alias "__vbaCastObj" (pObj As Any, riid As UUID) As LongPtr
    Since tB allows substitute a LongPtr for UUID if you really wanted to.
    Last edited by fafalone; Jan 15th, 2025 at 07:00 AM.

  15. #15

    Thread Starter
    Fanatic Member HackerVlad's Avatar
    Join Date
    Nov 2023
    Posts
    587

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    Hurray! This is great news, especially for people who use the code from The Trick, where this feature is present.

    I also wanted to see if you could add undocumented features to WinDevLib from shlwapi.dll? I am interested in the functions SHWeakQueryInterface, SHInterlockedCompareExchange, SHWeakReleaseInterface.

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

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    Yup whenever I see an undocumented/missing API I add it.

    Those have already been added for the next version. Currently just waiting to see if a bug related to delegates is fixed soon to see if I should finish what I started with putting them back or remove them all again.

    Code:
    Public Declare PtrSafe Function SHWeakQueryInterface Lib "shlwapi" Alias "#267" (ByVal pUnkOuter As LongPtr, ByVal punkInner As LongPtr, riid As UUID, ppv As Any) As Long
    Public Declare PtrSafe Function SHInterlockedCompareExchange Lib "shlwapi" Alias "#342" (ppDest As Any, pExch As Any, pComp As Any) As LongPtr
    Public Declare PtrSafe Sub SHWeakReleaseInterface Lib "shlwapi" Alias "#268" (ByVal pUnkOuter As LongPtr, ByVal ppunk As LongPtr)

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

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    The above APIs are now available in the public WinDevLib package as of v8.7.485

  18. #18
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,973

    Re: Why doesn't the "__vbaCastObj" function work in Twin Basic?

    Quote Originally Posted by HackerVlad View Post
    Hurray! This is great news, especially for people who use the code from The Trick, where this feature is present.

    I also wanted to see if you could add undocumented features to WinDevLib from shlwapi.dll? I am interested in the functions SHWeakQueryInterface, SHInterlockedCompareExchange, SHWeakReleaseInterface.
    I wanted to wrap VB6 into a 64-bit version by calling com DLLs dynamically and loading VB. Net DLL functionality dynamically. And it failed.

    Purely using APIs or various memory pointer operations. The VB. Net support is not very good.
    I once saw a Japanese develop it. The excel VBA calls the .net framework class library, and there are some special uses, maybe for better performance to get some special functions, they always use some strange functions.
    But it has to be said that he is very simple and violent.

    For example, VBA, VB6, can subclass some. Or the timer's function calls back a private function that runs above the class object.
    This function is not understood by most of us, but it is really convenient. It just doesn't support 64-bit.
    It may only take a few words of assembly code, but there's always a first person to implement it.Now the VB6 language and the VB.net have been abandoned, so people with technology will not study it.

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