Results 1 to 7 of 7

Thread: Typelib translation: is in,out BYTE somevar[8] a pointer?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,936

    Typelib translation: is in,out BYTE somevar[8] a pointer?

    If I saw this in a UDT I know the answer is no, and even if I saw it as plain in; but since I'm always getting errors about out parameters needing to be pointers...

    What's the correct simplification of this for consumption by VB6:

    Code:
        HRESULT TransferObjectData(
            ...,
            /* [out][in] */ __RPC__inout_ecount_full(WMDM_MAC_LENGTH) BYTE abMac[8]
        );
    (WMDM_MAC_LENGTH is also 8).

    BYTE* abMac for a ByRef Byte, or CURRENCY abMac for an 8-byte ByVal, changing it to in only?

  2. #2

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,936

    Re: Typelib translation: is in,out BYTE somevar[8] a pointer?

    You can pass a ByVal 8 bytes to As Any? And it puts them all on the stack?

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

    Re: Typelib translation: is in,out BYTE somevar[8] a pointer?

    No idea mate, I was just saying. Now that you put it that way I guess a Currency is the safe bet here.

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,656

    Re: Typelib translation: is in,out BYTE somevar[8] a pointer?

    My instinct is that it's a pointer to a byte array because in C pointers and arrays can be used interchangeably with some caveats.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,294

    Re: Typelib translation: is in,out BYTE somevar[8] a pointer?

    Quote Originally Posted by Niya View Post
    My instinct is that it's a pointer to a byte array because in C pointers and arrays can be used interchangeably with some caveats.
    Yep, have rarely seen a TypeLib-param flagged with [out], which wasn't one.

    In that regard, the "As Any"(Ptr) recommendation from VGG was not *that* bad...

    Olaf

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

    Re: Typelib translation: is in,out BYTE somevar[8] a pointer?

    8 is pretty small size for a MAC and thats why you can get away with Currency here. The array is not passed on the stack, it’s just a pointer and obviously you have to declare the Currency ByRef (provided that it’s in/out param). The size of the array (on the parameter) is just a hint, it’a not used by C/C++/MDL compiler in any way. MDL needs more attribs to provide proxy/stub impl which copies right sized blob.

    Anyway, if it was larger array (say 16) then you might need to declare it ByRef array As Byte and expect argument to be part of array i.e. baMac(0) so there are 15 more bytes past baMac(0) starting byte. This is extremely error prone and that’s why As Any is not bad convention to warn care should be taken, use at your own risk.

    Another option is to wrap the C array in a UDT and pass this ByRef. Unfortunately the wrapped array cannot vary in size but this is not the case here. So something like ArrayByte8 as a name is quite obvious, convenient and harmless (not error prone)

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