Re: Dll function which return a Pointer



In article <1128091361.850039.66000@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
aleicaro@xxxxxxxxx says...
> Hi,
> I've a funcion in a DLL which return a pointer to a structure (Record)
> of mine.
> I've a problem:
> When I return the pointer from my DLL, I've the Pointer with the right
> value, but if I go in MyPointer^.myField, it gives me "Access
> violation".
>
> The definition of my function is right (with stdcall) both in the exe
> and in the dll.
> I haven't many experience with dlls, but in my opinion, the problem, is
> that the memory where is stored my record valued from the dll is
> cleaned when I return to my exe?
>
> Is it right?
>
> How can I solve it?
> Thank you

Where do you create your record?
I always create the record in my main application, not the dll, and pass
to dll the address of the record.

Post the DLL code.

--
I'm not having these two shag while I'm tied to a chair three feet away.
.



Relevant Pages

  • Re: new - delete issue
    ... EXE calls a DLL exported function that return a struct pointer. ... The EXE call another exported function that delete all pointers in that list. ...
    (microsoft.public.vc.mfc)
  • Re: Notify multiple instances of my COM dll to take an action
    ... my dll default interface is derived from IUnknown and the exe ... passing the pointer into the exe but the method call on that pointer ...
    (microsoft.public.vc.atl)
  • Re: Critical section shared betwen dll and main program
    ... different components like EXE and DLL. ... old version of CRITICAL_SECTION and passes a pointer to it which is used ... There is no problem with passing its address between exe and DLL. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Structure containing string across DLL boundary
    ... Exe and DLL both built with static RTL. ... Debug build has no issues. ... The DLL allocates the structure with the embedded string. ... The function in the exe is invoked with a pointer to the structure and then ...
    (microsoft.public.vc.stl)
  • Re: Critical section shared betwen dll and main program
    ... I would not suggest to pass pointer to any structure between ... different components like EXE and DLL. ... Binary Environment) bug. ... EXE, which was compiled in a newer environment, with another ...
    (microsoft.public.win32.programmer.kernel)