📄 test.dpr
字号:
program Test;
uses
Forms,
Windows,
Messages,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
var
wHandle: THandle;
paraData: COPYDATASTRUCT;
sMsg: string;
I: Word;
begin
Application.Initialize;
CreateMutex(nil, true, 'PowerCTI');
if GetLastError = ERROR_ALREADY_EXISTS then
begin
//激活已经存在的程序窗口
wHandle := FindWindow(nil, 'Form1');
if wHandle <> 0 then
begin
ShowWindow(wHandle, SW_RESTORE);//恢复已执行程序窗口
SetForegroundWindow(wHandle); //提到最前面
sMsg:='';
if ParamCount > 0 then //如果参数大于0
begin
for I := 1 to ParamCount do
sMsg :=sMsg+paramstr(I)+';'; //可以任意制定格式,便于解析
paraData.dwData := 0; //这个不用改动,可作为格式参数使用
paraData.cbData := length(sMsg) + 1; //数据长度
paraData.lpData := Pchar(sMsg); //数据地址
SendMessage(wHandle, WM_COPYDATA, wHandle, integer(@paraData));
end;
end;
end
else
begin
Application.CreateForm(TForm1, Form1);
Application.Run;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -