只一次启动后,读取文件关联后的paramstr(1)为什么不行啊?
//在检测到已经启动后TIMER无法捕获ParamStr(1)而读取?
//而《网文快捕》做到了,如何处理啊??
program Project1;
uses
  Forms,
  Windows,
  Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
var
 Mutex:THandle;
 PrvHWND: HWND;
begin
  hasread:=false;
  Mutex:=CreateMutex(NIL,True,'文件关联测试');
  IF GetLastError<>ERROR_ALREADY_EXISTS THEN
  BEGIN
   Application.Initialize;
   Application.Title := '文件关联测试';
   Application.CreateForm(TForm1, Form1);
   Application.Run;
  end
  else
  begin
       if hasread then
       MyMsgBox(Paramstr(1),'已经启动-已读',2)
       else
       MyMsgBox(Paramstr(1),'已经启动-未读',2) ;
       PrvHWND := FindWindow('TApplication','文件关联测试');
       if IsIconic(PrvHWND) then
       begin
         ShowWindow(PrvHWND, SW_RESTORE);
       end;
       SetForegroundWindow(PrvHWND);
  end;
end.
//-----------------------------------------------------
procedure TForm1.Timer1Timer(Sender: TObject);
var
 s:string;  //在检测到已经启动后TIMER无法捕获ParamStr(1)而读取?
begin
if not hasread then
 begin
   s:= ParamStr(1) ;
   if ParamStr(1)<>'' then
    begin
      memo1.Lines.LoadFromFile( ParamStr(1));
      hasread:=true;
    end;
 end;
end;
//-----------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject);
var
lphKey: HKEY;
sKeyName: string;
sKeyValue: string;
mys:string;
begin
mys:=application.ExeName ;
sKeyName := 'aaa.FileType';
sKeyValue := '我的AAA文件关联';
RegCreateKey(HKEY_CLASSES_ROOT,pchar(sKeyName), lphKey);
RegSetValue(lphKey, '', REG_SZ,pchar(sKeyValue), 0);
sKeyName := '.aaa';
sKeyValue := 'aaa.FileType';
RegCreateKey(HKEY_CLASSES_ROOT,pchar(sKeyName), lphKey);
RegSetValue(lphKey, '', REG_SZ,pchar(sKeyValue), 0);
sKeyName := 'aaa.FileType';
sKeyValue := '"'+mys+'"'+' "%1"';
RegCreateKey(HKEY_CLASSES_ROOT,pchar(sKeyName), lphKey);
RegSetValue(lphKey, 'Shell\Open\Command', REG_SZ,pchar(sKeyValue), MAX_PATH);
sKeyName := 'aaa.FileType';
sKeyValue := mys+',0';
RegCreateKey(HKEY_CLASSES_ROOT,pchar(sKeyName), lphKey);
RegSetValue(lphKey, 'DefaultIcon', REG_SZ,pchar(sKeyValue), MAX_PATH);
end;