V
V
vSkyD12015-12-09 19:47:51
Java
vSkyD1, 2015-12-09 19:47:51

How to pass a char pointer to a dll function so that it can be further parsed into an array?

Hello.
I work in the environment: C# - main project, C++ - library.
I will shorten my code to point out the problem.

What, in fact, is the question, is there a dll in C ++ with such a function

LaunchJavaApplet(char* JVMOptions[]){
...
  JavaVMOption *Options = new JavaVMOption[JVMOptionsCount];
  for (int i = 0; i < JVMOptionsCount; i++) {
    Options[i].optionString = (char*)(JVMOptions[i]);
  }
...
}

The library is not mine, I did not write it. But its author says that you need to pass an "array of pointers" to JVMOptions in order to divide into lines, in fact, you see this in the loop. Everything would be fine, if not for one BUT: how can I pass a string to a C # project ...
(
Example:
-Xmx512m -Xms1024m
this is how an array should look like, one parameter per 1 cell of the array, how to do it for pointers ... and to then place the pointers through the loop into the strings... xs :/
)
... into this library so that the library can divide it into strings.

Let me explain some points:
JVMOptionsCount - also passed to the function, this is the number of arguments (-Xmx512m) that I pass to the function
JVMOptions - there should be an array that will be filled with arguments on the sharp, but how to make an array on the sharp so that it is pointers .... brbrp ... confused, horror ... ahhh ... it was not easier to make an array in the library right away ... why pointers then ...
This is how the result of the cycle should look like:
Options[0].optionString = "-Xmx512m";
Options[1].optionString = "-Xms1024m";

I hope for your help, because it turns out that my level of knowledge of pointers is very low for coding

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2015-12-09
@vSkyD1

[DllImport("вашалиба.dll", CharSet = Ansi, CallingConvention = CallingConvention.Cdecl)]
public void LaunchJavaApplet([In] string[] JVMOptions);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question