greatwall
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Downloads
Gallery
Posts posted by greatwall
-
-
hi,
I am in trouble now!
I have a dll , i want get same altered values from the parameters by passing pointers as arguments to a function.my function definition is as following.
========mydll.h========
##ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) char *str (int *num,char **ch);
#ifdef __cplusplus
}
#endif
=========mydll.cpp======
#include "mydll.h"
char *str(int *num,char **ch)
{
char *pstr = "this is string!";
*num = 10;
*ch =pstr;
return *ch;
}
and then I create another project to test this dll ,it works correctly. but if I use labview to call the dll,it is incorrect.
in c++,call the function as follows:
int a = 0;
char *b ="";
char *rtnStr = str ( &a,&b);
after executing the "str" function,the return value and all arguments are:
a = 10;
b = this is string!
rtnStr = this is string!
but in labview, I wrap this dll by setting return value as string(c string pointer),setting parameters as numeric (pointer to value) and string(c string pointer).
I think my setting is correct!
but the result is incorrect!
a = 10
b =(unknowing char)
rtnStr = this is string!
Why "b" can not get the string as calling in C++? if I want to get the value by passing pointer. How should I do ?
the issue of calling dll passing arguments by pointer
in Calling External Code
Posted
QUOTE (bsvingen @ Apr 6 2009, 02:59 PM)
thanks very much!
It is not a good idea to use dlls returning pointer argument ,I think so too. because the dll is not mine, I only have the head file and dll, it seems that I must re-disposal it in C++. thanks again!