Jerry Guest
|
Posted: Mon Jan 03, 2005 10:18 pm Post subject: Re: "Invalid Pointer Operation" when using Dispose() or Free |
|
|
Hey, your answer hellped me find my problem: using a pointer to a
pointer.
I ended up writing to memory I allocated, but freed the wrong pointer.
After I figured out what I had done, everything worked just fine!
Brien King wrote:
| Quote: | (***************Here's the trouble
*****************************)
new(ThePFI); {<==========
method# 1}
GetMem(ASecondPFI, sizeof(TVS_FixedFileInfo)); {<=====method
#2}
pchar(AThirdPFI):=StrAlloc(Sizeof(TVS_FIXEDFILEINFO));
{<=The hack, #3}
VerQueryValue(pszData, '', pointer(ThePFI) , wLen);
VerQueryValue(pszData, '', pointer(ASecondPFI) , wLen);
VerQueryValue(pszData, '', pointer(AThirdPFI) , wLen);
StrDispose(pszData);
Strdispose(pchar(AThirdPFI)); {<==The hack works}
Dispose(ThePFI); {<==Invalid Pointer
Operation"!}
FreeMem(ASecondPFI, sizeof(TVS_FixedFileInfo)); {<==also
invalid}
end.
Since "ThePFI" is already a Pointer, why the pointer(ThePFI)? This
could be your problem. Since I do not know what VerQueryValue does
with the parameters (nor how they are actually defined) I would say
this is your problem. It looks as though your attempting to pass the
structure in by Reference and then fill it in. However, what you may
actually be doing is passing in an Invalid Pointer, or a pointer to
the pointer (can't remember off the top of my head what pointer(x)
does). If you try your code without the VerQueryValue in the middle
so all you have is New(ThePFI) and then Dispose(ThePFI) I bet it
would
work.
Brien King
[email]bking (AT) primenet (DOT) com[/email]
|
|
|