Jump to content
Excelsior Forums
Sign in to follow this  
merlin

How to call a C++ function that takes a BYTE* arg.

Recommended Posts

Hello,

I have to call a C++ function foo(BYTE* pBuffer). Unfortunately there seems to be no type in xFunction that matches BYTE.

I tried to use char instead:

xFunction foo = new xFunction("foo_DLL", "foo(char*)");

Pointer p = Pointer.create("char*");

foo.invoke(p);

This does not seem to work.

I do not no if this problem is trivial since I am new to xFunction.

Please help!

Greetings,

--Alex

Share this post


Link to post
Share on other sites

Using of char* for BYTE* is correct, but it seems that in your example pBuffer should be an array of BYTE. It is not clear from your description whether it is the buffer for input or output. In the last case, you may use the following code:

 Pointer p = (Pointer)Argument.create("char*", new char[20]);

 foo.invoke(p);

 char[] result = (char[])p.createArray(20);

Here '20' stands for the length of the buffer supposed by the function foo()

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×