Re: __declspec(dllexport) to return char but errors in VB6



Thank you for your reply!

I was switching code around and placed the FreeHGlobal in the wrong place
for my post.

changing it to this

WDINFO_LINKAGE char* getWdInfo(char* Param){

IntPtr ptr = Marshal::StringToHGlobalAnsi(S"Testing return");
char __nogc* pStr = static_cast<char*>(ptr.ToPointer());

return pStr;

Marshal::FreeHGlobal(ptr);
}

doesn't give me the error but doesn't return anything back.

Thanks in advance.

Jason
Wood


"Mattias Sjögren" <mattias.dont.want.spam@xxxxxxxx> wrote in message
news:u2TT0nbkFHA.2852@xxxxxxxxxxxxxxxxxxxxxxx
> >Can any one explain what I am doing wrong?
>
> The pointer you're returning is invalid since you just freed the
> memory it points to.
>
>
>
> Mattias
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.


.



Relevant Pages


Loading