You've already forked lazarus-ccr
DeleteShortCut public function added
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5714 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -3,14 +3,14 @@
|
||||
<ProjectSession>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="10"/>
|
||||
<BuildModes Active="Linux32"/>
|
||||
<BuildModes Active="Win64"/>
|
||||
<Units Count="28">
|
||||
<Unit0>
|
||||
<Filename Value="testapp.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<CursorPos X="25" Y="28"/>
|
||||
<UsageCount Value="64"/>
|
||||
<UsageCount Value="65"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
@ -19,9 +19,9 @@
|
||||
<ComponentName Value="mainform"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<TopLine Value="8"/>
|
||||
<CursorPos X="16" Y="15"/>
|
||||
<UsageCount Value="64"/>
|
||||
<TopLine Value="157"/>
|
||||
<CursorPos X="4" Y="176"/>
|
||||
<UsageCount Value="65"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
</Unit1>
|
||||
@ -32,7 +32,7 @@
|
||||
<WindowIndex Value="1"/>
|
||||
<TopLine Value="31"/>
|
||||
<CursorPos X="48" Y="14"/>
|
||||
<UsageCount Value="47"/>
|
||||
<UsageCount Value="48"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\lazautoupdate_httpclient.pas"/>
|
||||
@ -43,15 +43,15 @@
|
||||
<Unit4>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<WindowIndex Value="1"/>
|
||||
<TopLine Value="1707"/>
|
||||
<CursorPos X="73" Y="1722"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="317"/>
|
||||
<CursorPos X="41" Y="357"/>
|
||||
<ExtraEditorCount Value="2"/>
|
||||
<ExtraEditor1>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="466"/>
|
||||
<CursorPos X="37" Y="476"/>
|
||||
<WindowIndex Value="1"/>
|
||||
<TopLine Value="1724"/>
|
||||
<CursorPos X="45" Y="1733"/>
|
||||
</ExtraEditor1>
|
||||
<ExtraEditor2>
|
||||
<EditorIndex Value="-1"/>
|
||||
@ -187,8 +187,8 @@
|
||||
<Unit22>
|
||||
<Filename Value="..\ushortcut.pas"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<TopLine Value="71"/>
|
||||
<CursorPos X="34" Y="106"/>
|
||||
<TopLine Value="178"/>
|
||||
<CursorPos X="44" Y="213"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit22>
|
||||
@ -234,129 +234,126 @@
|
||||
<OtherDefines Count="1">
|
||||
<Define0 Value="DEBUGMODE"/>
|
||||
</OtherDefines>
|
||||
<General>
|
||||
<ActiveWindowIndexAtStart Value="1"/>
|
||||
</General>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="242" Column="24" TopLine="214"/>
|
||||
<Caret Line="232" Column="36" TopLine="214"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="241" Column="34" TopLine="215"/>
|
||||
<Caret Line="281" Column="45" TopLine="259"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="232" Column="37" TopLine="214"/>
|
||||
<Caret Line="243" TopLine="223"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="C:\laztrunk\fpc\rtl\objpas\classes\classesh.inc"/>
|
||||
<Caret Line="426" Column="30" TopLine="399"/>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="241" Column="43" TopLine="214"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="232" Column="36" TopLine="214"/>
|
||||
<Caret Line="251" Column="21" TopLine="223"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="281" Column="45" TopLine="259"/>
|
||||
<Caret Line="679" Column="49" TopLine="658"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="243" TopLine="223"/>
|
||||
<Caret Line="701" Column="38" TopLine="687"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="241" Column="43" TopLine="214"/>
|
||||
<Caret Line="457" Column="37" TopLine="444"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="251" Column="21" TopLine="223"/>
|
||||
<Caret Line="466" Column="23" TopLine="452"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="679" Column="49" TopLine="658"/>
|
||||
<Caret Line="470" Column="40" TopLine="460"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="701" Column="38" TopLine="687"/>
|
||||
<Caret Line="583" Column="36" TopLine="552"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="457" Column="37" TopLine="444"/>
|
||||
<Caret Line="553" TopLine="529"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="466" Column="23" TopLine="452"/>
|
||||
<Caret Line="545" Column="6" TopLine="523"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="470" Column="40" TopLine="460"/>
|
||||
<Caret Line="61" Column="74" TopLine="50"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="583" Column="36" TopLine="552"/>
|
||||
<Caret Line="570" Column="28" TopLine="542"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="553" TopLine="529"/>
|
||||
<Caret Line="621" Column="46" TopLine="582"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="545" Column="6" TopLine="523"/>
|
||||
<Caret Line="629" Column="65" TopLine="593"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="61" Column="74" TopLine="50"/>
|
||||
<Caret Line="637" Column="51" TopLine="615"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="570" Column="28" TopLine="542"/>
|
||||
<Caret Line="639" Column="8" TopLine="615"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="621" Column="46" TopLine="582"/>
|
||||
<Caret Line="637" Column="50" TopLine="616"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="629" Column="65" TopLine="593"/>
|
||||
<Caret Line="971" Column="61" TopLine="944"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="637" Column="51" TopLine="615"/>
|
||||
<Caret Line="480" Column="20" TopLine="448"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="639" Column="8" TopLine="615"/>
|
||||
<Caret Line="785" TopLine="758"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="637" Column="50" TopLine="616"/>
|
||||
<Caret Line="784" Column="41" TopLine="757"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="971" Column="61" TopLine="944"/>
|
||||
<Caret Line="474" TopLine="456"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="480" Column="20" TopLine="448"/>
|
||||
<Caret Line="966" Column="70" TopLine="931"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="785" TopLine="758"/>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="15" Column="16" TopLine="8"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="784" Column="41" TopLine="757"/>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="152" Column="37" TopLine="146"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="474" TopLine="456"/>
|
||||
<Filename Value="umainform.pas"/>
|
||||
<Caret Line="154" Column="37" TopLine="148"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<Caret Line="966" Column="70" TopLine="931"/>
|
||||
<Caret Line="1014" Column="57" TopLine="977"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectSession>
|
||||
|
@ -1,7 +1,7 @@
|
||||
object mainform: Tmainform
|
||||
Left = 509
|
||||
Left = 518
|
||||
Height = 209
|
||||
Top = 326
|
||||
Top = 285
|
||||
Width = 335
|
||||
BorderIcons = [biSystemMenu]
|
||||
Caption = 'mainform'
|
||||
@ -93,6 +93,15 @@ object mainform: Tmainform
|
||||
TabOrder = 6
|
||||
Visible = False
|
||||
end
|
||||
object cmd_MakeDesktopShortcut: TButton
|
||||
Left = 184
|
||||
Height = 25
|
||||
Top = 112
|
||||
Width = 139
|
||||
Caption = 'Make Desktop Shortcut'
|
||||
OnClick = cmd_MakeDesktopShortcutClick
|
||||
TabOrder = 7
|
||||
end
|
||||
object LazAutoUpdate1: TLazAutoUpdate
|
||||
About.Description.Strings = (
|
||||
'A component for updating your application'#13#10'Designed for projects hosted by SourceForge'#13#10#13#10'Main methods:'#13#10'Procedure AutoUpdate'#13#10'Function NewVersionAvailable: Boolean'#13#10'Function DownloadNewVersion: Boolean'#13#10'Function UpdateToNewVersion: Boolean'#13#10'Procedure ShowWhatsNewIfAvailable'#13#10'For troubleshooting, set DebugMode=TRUE'
|
||||
@ -126,7 +135,7 @@ object mainform: Tmainform
|
||||
GitHubRepositoryName = 'TestApp'
|
||||
GitHubBranchOrTag = 'updates'
|
||||
ShortCut.ShortcutName = 'AnotherName'
|
||||
ShortCut.Category = scUtility
|
||||
ShortCut.Category = scAudioVideo
|
||||
Left = 200
|
||||
Top = 24
|
||||
end
|
||||
|
@ -45,6 +45,7 @@ type
|
||||
{ Tmainform }
|
||||
|
||||
Tmainform = class(TForm)
|
||||
cmd_MakeDesktopShortcut: TButton;
|
||||
cmd_SilentUpdate: TButton;
|
||||
cmd_AutoUpdate: TButton;
|
||||
cmd_updateToNewVersion: TButton;
|
||||
@ -56,6 +57,7 @@ type
|
||||
StatusBar1: TStatusBar;
|
||||
procedure cmd_AutoUpdateClick(Sender: TObject);
|
||||
procedure cmd_DownloadNewVersionClick(Sender: TObject);
|
||||
procedure cmd_MakeDesktopShortcutClick(Sender: TObject);
|
||||
procedure cmd_NewVersionAvailableClick(Sender: TObject);
|
||||
procedure cmd_SilentUpdateClick(Sender: TObject);
|
||||
procedure cmd_updateToNewVersionClick(Sender: TObject);
|
||||
@ -163,6 +165,17 @@ begin
|
||||
LazAutoUpdate1.DownloadNewVersion;
|
||||
end;
|
||||
|
||||
procedure Tmainform.cmd_MakeDesktopShortcutClick(Sender: TObject);
|
||||
begin
|
||||
LazAutoUpdate1.ShortCut.ShortCutName:='Test Application';
|
||||
LazAutoUpdate1.ShortCut.Target:=Application.EXEName;
|
||||
LazAutoUpdate1.ShortCut.IconFilename:=ChangeFileExt(Application.EXEName,'.ico');
|
||||
If LazAutoUpdate1.MakeShortCut then
|
||||
ShowMessage('Success! New shortcut is now on your desktop')
|
||||
else
|
||||
ShowMessage('MakeShortCut failed');
|
||||
end;
|
||||
|
||||
procedure Tmainform.cmd_AutoUpdateClick(Sender: TObject);
|
||||
begin
|
||||
{$IFDEF DEBUGMODE}
|
||||
|
@ -356,6 +356,7 @@ type
|
||||
procedure RelocateLauImportFile;
|
||||
// Uses properties in TShortCutClass
|
||||
function MakeShortCut: boolean;
|
||||
function DeleteShortCut: boolean; // (use fShortCutClass.ShortCutName)
|
||||
|
||||
// Download lists (now superceded by CopyTree)
|
||||
// TODO: Use Indexed properties to handle list access
|
||||
@ -966,7 +967,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// A couple of public functions for installer apps
|
||||
function TLazAutoUpdate.MakeShortCut: boolean;
|
||||
begin
|
||||
Result := False; // assume failure, look for success
|
||||
@ -996,6 +997,22 @@ begin
|
||||
fShortCutClass.TargetArguments, fShortCutClass.ShortcutName,
|
||||
fShortCutClass.IconFileName, fShortCutClass.CategoryString);
|
||||
end;
|
||||
function TLazAutoUpdate.DeleteShortCut: boolean;
|
||||
begin
|
||||
Result := False; // assume failure, look for success
|
||||
if Assigned(fOndebugEvent) then
|
||||
fFireDebugEvent := True;
|
||||
|
||||
if fFireDebugEvent then
|
||||
fOndebugEvent(Self, 'DeleteShortCut', 'DeleteShortCut called');
|
||||
If fShortCutClass.ShortcutName='' then
|
||||
begin
|
||||
if fFireDebugEvent then
|
||||
fOndebugEvent(Self, 'DeleteShortCut', 'ShortCut.ShortCutName was empty!');
|
||||
Exit;
|
||||
end;
|
||||
Result:=DeleteDesktopShortcut(fShortCutClass.ShortCutName);
|
||||
end;
|
||||
|
||||
procedure TLazAutoUpdate.ShowWhatsNewIfAvailable;
|
||||
begin
|
||||
|
@ -83,6 +83,8 @@ uses
|
||||
function CreateDesktopShortCut(Target, TargetArguments, ShortcutName,
|
||||
IconFileName, Category: string): boolean;
|
||||
|
||||
function DeleteDesktopShortcut(ShortcutName: string):Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF UNIX}
|
||||
@ -208,18 +210,24 @@ end;
|
||||
|
||||
{$ENDIF UNIX}
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure DeleteDesktopShortcut(ShortcutName: string);
|
||||
Function DeleteDesktopShortcut(ShortcutName: string):Boolean;
|
||||
var
|
||||
PIDL: PItemIDList;
|
||||
InFolder: array[0..MAX_PATH] of char;
|
||||
LinkName: WideString;
|
||||
begin
|
||||
Result:=FALSE;
|
||||
{ Get the desktop location }
|
||||
SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, PIDL);
|
||||
SHGetPathFromIDList(PIDL, InFolder);
|
||||
LinkName := IncludeTrailingPathDelimiter(InFolder) + ShortcutName + '.lnk';
|
||||
SysUtils.DeleteFile(LinkName);
|
||||
If SysUtils.DeleteFile(LinkName) then Result:=TRUE;
|
||||
end;
|
||||
{$ELSE}
|
||||
Function DeleteDesktopShortcut(ShortcutName: string):Boolean;
|
||||
begin
|
||||
Result:=FALSE;
|
||||
end;
|
||||
|
||||
{$ENDIF MSWINDOWS}
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user