-
Apr 12th, 2024, 09:33 AM
#1
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?
-
Apr 12th, 2024, 09:40 AM
#2
Re: Typelib translation: is in,out BYTE somevar[8] a pointer?
"As Any" and you could pass either.
-
Apr 12th, 2024, 11:35 AM
#3
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?
-
Apr 12th, 2024, 11:44 AM
#4
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.
-
Apr 12th, 2024, 09:55 PM
#5
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.
-
Apr 13th, 2024, 01:29 AM
#6
Re: Typelib translation: is in,out BYTE somevar[8] a pointer?
 Originally Posted by Niya
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
-
Apr 13th, 2024, 03:15 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|