Problem with Pointers and DLL's

Quote
Petter Kvinlaug <pette...@oslonett.no> wrote:
>I'm trying to use some DLL's from the Reflection API. Some of them return pointers in the
>parameterlist. The interface to the DLL goes something like this:

>Type
>   TWindowID = ^Longint;

>Function rcGetWindowByIndex(var1:Longint; Var Var2:PWindowID):Word; External 'R8API';

>Main Program:

>Var
>   PWindowID:TWindowID;
>   Result:Word;
>   WinNum,ID:Longint;

>Begin
>   .
>   .
>    Result:=rcGetWindowByIndex(WinNum,PWindowID);

>So far so good. I can see from the de{*word*81} that Result=0 (That's OK) and
>the pointer (PWindowID) points to the correct value.

>But when i'm trying to transfer that value to a variable, like this;

>    ID:=WindowID^;

>Windows reponds width a General Protection Fault.
>How can I transfer the value that WindowID points to, to a variable Without getting GP faults.

I think that you may not be initialising your PWindowID variable ?

Have you got :-

        new( PWindowID )

in your code somewhere before the call to rcGetWindowByIndex() ?

Let me know if this sorts it please.
Scott Paterson
Willenhall, West Mids, UK.