Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to Delphi, probably an obvious Array question

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
GB
I must point out first that until three hours ago I hadn't used Delphi, and most of the code below is from a forum, so I apologise for my ignorance in advance.

The code compiles into a DLL which provides MAPI services for a Visual Basic email application. When MAPISendMail is triggered in this DLL it writes the name of the file being emailed into the Registry and broadcasts a message which my VB application picks up, and from there onwards can create an email. The code below works perfectly if the Windows user wants to email a single file, but if they choose to email several at once it only passes the first file they choose.

My question is how to deal with multiple files. Within the lpMessage structure the lpFiles parameter is supposed to be an array. However, I've tried different ways of processing it as an Array but they all cause the parent application to crash.

Code:
uses
    Windows
    , MAPI
    , REGISTRY
    , SysUtils
    ;

function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal; var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal; stdcall;

implementation

function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal; var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal; stdcall;
Var MyReg : tregistry;
begin
    MyReg:=Tregistry.create;
    MyReg.rootkey:=HKEY_CURRENT_USER;
    if MyReg.openkey('SOFTWARE\Apt\TCM\', true) then
      begin
        MyReg.writeString('MAPISendMailFile', lpMessage.lpFiles.lpszPathName);
        MyReg.writeString('MAPISendMailSubject', lpMessage.lpszSubject);
        MyReg.Closekey;
      end;
    MyReg.free;

    SendMessage(65535, 50020, 10007, 0);

    Result  := SUCCESS_SUCCESS;
end;

Ideally I'd like a solution that sets the Registry value "MAPISendMailFile" to be a semi-colon delimited list of files. (The code above omits the other MAPI functions which appear in the DLL but I don't think they're relevant to this problem).

Any help would be much appreciated.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Sometimes this type of structure is handled by separating the filenames with a null character. Try viewing the parameter value as an array of char.

Also - sometimes these functions have callback parameters so you send a parameter to the function to get the length of a string or a number of elements in an array and then you call the function again with a different set of parameters to handle the actual data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top