Home > Net >  Everyone a great god, vb.net call c DLL, the return value is a pointer type. What should I do?
Everyone a great god, vb.net call c DLL, the return value is a pointer type. What should I do?

Time:10-16

Everyone a great god, help me, written in c vb.net call DLL, the return value is a pointer type, and I don't know how to receive this return pointer type data in the vb.net, please take your action,

CodePudding user response:

refer to the original poster l312674055 response:
everyone a great god, help me, written in c vb.net call DLL, the return value is a pointer type, and I don't know how to receive this return pointer type data in the vb.net, please action,

Vb.net defines a pointer with IntPtr, such As Dim ptObject As IntPtr

CodePudding user response:

IntPtr

CodePudding user response:

About can have such a few practices, the first is the pointer to directly to the API statement statement for structure, to save trouble, because the structure of the reference is a pointer is passed,,,, the second is declared as a pointer then use Marshal class read pointer prt2st method in the structure of the body back,,, you don't provide the function prototype, then, if all kinds of memory errors, such as yourself to try more byval or byref is right

CodePudding user response:

Returns a pointer, then the return value must be a string or structure
General use IntPtr receive then
Marshal. PtrToStringAnsi
Marshal. PtrToStructure
To transform the
If the structure is, of course. You will need the same structure and defined in c + + type

CodePudding user response:

Look at the documents, anything can be a pointer in C, a structure he can return pointer, he can return a string pointer, a callback he can also return a pointer

So you ask a pointer, we can't save,

CodePudding user response:

https://bbs.csdn.net/topics/392401666

To see this post, he in the same way as you ask, then what, then, tell him that it might be anything, as a result, he was regarded as a fixed, he felt for the final answer, I can only say that last answer can only be "happened to returns the string"
  • Related