只一次启动后,读取文件关联后的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;
//在检测到已经启动后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;
解决方案 »
- 初学三层开发,一般的数据库操作已经可以了,如果把图片保存到数据库中怎么也搞不出来
- 在单步调试过程中碰到的怪问题?
- 算法问题,欢迎大家一起来帮忙讨论解决
- [求助]dbgrid用法
- 报表问题:怎样可以当Detail部分大的时候直接跟title部分打而不另起一页。
- 哪位大虾能告诉我,在Delphi中怎样执行其它应用软件。在线等候。
- Delphi + MO 做GIS系统是否BUG比较多?
- !!!绝对陷阱,千万别上当!!! !
- 如何实现不规则窗体的移动?
- delphi6中的Corba问题,请高手帮忙。
- ★★★哪位大哥可用分多的用不了,能否给小弟捐献一些,实在不行我用钱买!!!★★★
- 第一次在深圳一家外企公司面试。
.... if hasread then
MyMsgBox(Paramstr(1),'已经启动-已读',2)
else
MyMsgBox(Paramstr(1),'已经启动-未读',2) ;這此好象沒什麼意義
那具体 要在怎么改啊!