Wind flower Snow Moon E-Dream Enthusiastic Network Code: Wnhoo Or Sos_admin Name: E Demon Mail: wnhoo@163.com
Function: When executed for the first time ... When Project1.exe is executed second time ... Do not open Project1.exe ... but will pose the parameters to the executed Project1.exe 3rd execution Time ... don't open Project1.exe (the factor is executed) ... but will pose the parameter to the executed project1.exe ...
[Public unit file] Unit UNLIB; InterfacePepar = RecordStr1: String [255]; str2: string [255]; str3: string [255]; end; importationnd.
[Project Document] Program Project1;
Usesforms, Unit1 in 'Unit1.Pas' {Form1}, Windows, Messages, Dialogs, Unlib in 'unlib.pas';
CONSTAPNAME = 'MyName'; varmyHandle: hwnd; rexdata: ^ copyDataStruct; ppar: ^ par; {$ r * .res}
beginmyhandle: = findwindow (appname, nil); beginGetMem (RexData, SizeOf (COPYDATASTRUCT)); GetMem (ppar, Sizeof (par)); with ppar ^ dobeginstr1: = ParamStr (1); str2: = ParamStr (2); Str3 : = Paramstr (3);
with RexData ^ dobegindwData: = myhandle; cbData: = Sizeof (par); lpData: = ppar; end; if myhandle> 0 then SendMessage (myhandle, WM_COPYDATA, 0, LONGINT (REXdATA)); FreeMem (RexData); FreeMem (ppar ); if myhandle> 0 THEN EXIT; End; Application.initialize; Application.createform (TFORM1, FORM1); Application.Run; End.
[Unit file] Unit unit1;
Interface
usesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, unlib; constappname = 'myname'; typeTForm1 = class (TForm) Memo1: TMemo; Memo2: TMemo; Memo3: TMemo; private {Private declarations PUBLIC
Procedure CreateParams (Var params: TcreateParams); Override; Procedure RestoreRequest (Var Msg: twmcopydata); Message WM_CopyData;
{Public declarations} END;
Varform1: TFORM1; Implementation
{$ R * .dfm} procedure tform1.createparams (var params: tcreateparams); begininherited createparams (params); params.winclassname: = appname;
procedure TForm1.restorerequest (var msg: TWMCopyData); varRexData: TCopyDataStruct; ppar: ^ par; beginif msg.CopyDataStruct <> nil thenbeginRexData: = msg.CopyDataStruct ^; ppar: = RexData.lpData; if ppar ^ .str1 = '' ThenMemo1.Lines.Add ('NOT Parameter') elseMemo1.Lines.Add (ppar ^ .str1);
If PPAR ^ .str2 = '' TenMemo2.Lines.Add ('NOT Parameter') elseMemo2.Lines.Add (ppar ^ .STR2);
If PPAR ^ .str3 = '' TenMEMO3.Lines.Add ('NOT Parameter') elseMemo3.Lines.Add (ppar ^ .str3);
END;
End.