{*******************************************************}
{ }
{ Pascal Script Source File }
{ Run by RemObjects Pascal Script in CnWizards }
{ }
{ Generated by CnPack IDE Wizards }
{ }
{*******************************************************}
{自动复制编译的文件到系统桌面脚本文件 }
{ 程序人生 email:LT66@21cn.com }
{借鉴了网上不少代码在此表示感谢 }
{只要在cnpack的脚本专家 smAfterCompile 打钩 }
{ }
{*******************************************************}
program cpfile;
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ToolsAPI, CnWizUtils, CnWizIdeUtils,Registry;
const
regPath = '\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders';
function GetShellFolders(strDir: string): string;
var
Reg: TRegistry;
strFolders: string;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey(regPath, false) then
begin
strFolders := Reg.ReadString(strDir);
end;
finally
Reg.Free;
end;
result := strFolders;
end;
function GetDeskeptPath: string;
begin
Result := GetShellFolders('Desktop'); //是取得桌面文件夹的路径
end;
var
CurPName,CurPath: Variant;
tmps: string;
Name1,mc: string;
IsFind: Boolean;
begin
Name1 := CnOtaGetCurrentProjectFileName;
CurPath := Name1;
if IsBdsProject(Name1) or IsDpr(Name1) then //是PE工程
begin
CnOtaGetActiveProjectOption('OutputDir',CurPName); //先获得输出目录
Name1 := ExtractFileName(Name1);
if Trim(CurPName) = '' then
begin
CurPName := CnOtaGetCurrentProjectFileNameEx+'.exe';
IsFind := FileExists(CurPName);
if not IsFind then
CurPName := CnOtaGetCurrentProjectFileNameEx+'.dll';
IsFind := FileExists(CurPName);
mc:=curpname;
Name1 := CurPName;
end
else
begin
Name1 := Copy(Name1,1,Pos('.',Name1)-1);
tmps := CurPName;
if tmps[Length(tmps)] <> '\' then
tmps := tmps + '\';
if Pos(':',tmps) <> 0 then
begin
Name1 := tmps + Name1 + '.exe';
IsFind := FileExists(Name1);
if not IsFind then
Name1 := tmps + Name1 + '.dll';
end
else
begin
CurPath := ExtractFilePath(CurPath);
CurPName := CurPath + tmps + Name1 + '.exe';
IsFind := FileExists(CurPName);
if not IsFind then
CurPName := CurPath + tmps + Name1 + '.dll';
Name1 := CurPName;
end;
IsFind := FileExists(Name1);
end;
if IsFind then
begin
mc:=ExtractFileName(name1);
copyfile(pchar(name1),GetDeskeptPath+'\'+mc,False); //false 时自动覆盖
end;
end;
end.