Dynamic linker call char * Return to empty solution

xiaoxiao2021-03-06  79

Please see this code:

Extern "C" __declspec (dllexport) char * __stdcall getStr (char * DDD)

{

Char * DDAA = "wwwwww"; return ddaa;

}

This is written, but there is no problem, but when the VB is called, it is empty.

The VB code is as follows:

Private Declare Function GetStr Lib "DLL2.DLL" (Byval Variable As String) AS STRING

Private sub fascist2_click ()

MSGBOX GetStr ("Sadfsad")

End Sub

Try it with this:

Char * ddaa = "wwwwww";

Maybe this is a problem, try the DDAA New a space, and assign it.

code show as below:

Extern "C" __declspec (dllexport) char * __stdcall getStr (char * DDD)

{

Char * ddaa = new char [6];

DDAA = "wwwwww";

Return DDAA;

}

Or not! Try again, use _TCSCPY ().

DDAA = "wwwwww";

Change to _TCSCPY (DDAA, "Wwwww");

Try it immediately.

success!

转载请注明原文地址:https://www.9cbs.com/read-94159.html

New Post(0)