I have some code that looks like this in my program:

var PTitle: PChar;

[...]

     if Trim(WTitle)<>'' then
     begin
          GetMem(PTitle,255);
          PTitle:=PChar(WTitle)
     end
     else PTitle:=nil;

[...]

     if PTitle<>nil then
        FreeMem(PTitle);

The application is calling this code with WTitle containing a string. It
goes alright up to the FreeMem statement when it throws "Invalid pointer
operation".

Is this supposed to be written some other way? I want to pass a nil pointer
in the FindWindow call or the pointer to a window title if passed in WTitle
(declared as PChar)

============================================
Patrick Dunford, Christchurch, NZ
EnzedRailWeb Sites
http://patrick.dunford.com/enzedrailweb/

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to