0

So, I'm basically looking to know how to turn this

BYTE *b
func(b);

into VB6 when b is a dynamic array that has already been redim'ed. Would it be

func(b)

or

func(VarPtr(b))

Thanks, iDomo.

0

1 Answer 1

3

You can do both, really.

But the easy way is func(b), where func is something like func(b() as byte). The b array is then passed by reference.

Sign up to request clarification or add additional context in comments.

4 Comments

What if the function's parameter needed to be a pointer to the array of bytes, in Long form?
@iDomo Is the function a native VB function, or is it Declared?
It's a native C compiled function. Private Declare Function ReadProcessMemory Lib "kernel32" (hProcess As Integer, lpBaseAddress As Long, lpBuffer As Long, nSize As Long, lpNumberOfBytesRead As Long) As Integer
@iDomo Then you shoud have phrased your question in a completely different way, as both the current question and answer have no relation to what you actually need. The function would be Private Declare Function ReadProcessMemory Lib "kernel32.dll" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesWritten As Long) As Long, and you would pass b(lbound(b)) for the third param. The function will receive the pointer to the first byte of the array. Do not omit ByVals, they are important.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.