Home > database >  Vc to write their own DLL call has a problem, to solve, thank you
Vc to write their own DLL call has a problem, to solve, thank you

Time:09-23

Himself wrote a vc DLL, the return type is char *, now the problem is that's right, in the vc messagebox display is right string, but spread to pb become garbled, if I am in the vc directly return string "XXX", is no problem in the pb, if char * re=a string, and then return re is garbled, how to return a responsibility?

CodePudding user response:

Char is a single-byte. As a result, PB in statement such function declarations for ANSI, such as:
The function string GetStr () library "YourDLL. DLL" alias for "GetStr; ANSI"

CodePudding user response:

reference 1st floor gaoqiangz response:
for char is a single-byte, so PB in such function declarations for ANSI, such as:
The function string GetStr () library "YourDLL. DLL" alias for "GetStr; ANSI "


Such statements pb error code directly, version pb9

CodePudding user response:

Returns a string error, to see your vc project is ANSI or UNICODE,
Suggest you still use UNICONDE code, would be to use, wcscpy function such as wide characters

CodePudding user response:

Preferably not return a pointer to a char *,
DLL usually return int indicating whether the result error, char * can be placed in parameter

Such as DLL

Int f_aa (char * chBuf, int BufLen)
{
//to manipulate
the character pointer}

//pb called

The FUNCTION long f_aa (ref string chBuf, long BufLen) LIBARAY "XXX. DLL
"
//call
String ls_buf
Long ll_len

Ll_len=100
Ls_buf=space (ll_len)

F_aa (ls_buf ll_len)

If the return value is a pointer in the DLL, release of memory involves a problem

CodePudding user response:

You return the pointer, is can't deal with pb, pb for Pointers processing are generally as the reference parameter of type, the incoming to deal with
  • Related