Hi all,

I am just wondering exactly how one should go about passing strings in
structures to API calls...

I have been mucking around with MAPI stuff and come across the following
when dealing with attachments:

  if Attachments.Count > 0 then
    GetMem(PtrMapiFileDescs, Attachments.Count * SizeOf(MapiFileDesc));
    for i := 0 to Attachments.Count - 1 do
      with PtrMapiFileDescs^[i] do begin
        ulReserved   := 0;
        flFlags      := 0;
        nPosition    := $FFFFFFFF;
        lpszPathName := PChar(Attachments[i]); {Attachments is a TStrings
object}
        lpszFileName := nil;
        lpFileType   := nil;
      end;

Now the above works when there is only 1 attachment, but if there are 2 then
the end of the filename of the first one gets screwed up by the writing of
the second. I can't really see why this occurs...

If I explicitly create a PChar and allocate space for it and assign the
attachment string to it, it all works fine...
Just more work involved making sure that you latter free the space assigned
to all the strings for each attachment...

Just wondering why the first method doesn't work for multiple attachments.

Regards
Colin

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

Reply via email to