Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 6 of 6 total |
Application installer |
Tue, Oct 27 2015 5:21 PM | Permanent Link |
Jeff Cook Aspect Systems Ltd | Hi
Sorry if this is horribly OT, but I can't find a suitable NG at Embarcadero for my question - and their NGs time out when I try and access them anyway. Hoping the good folk who inhabit the elevate community can help. I'm writing an installer program because it seems like the obvious thing to do. I'd normally head for Inno Setup (or rather my colleague would!), but since the setup involves so much SQL to set up the databases, create users, roles, stores etc. It seemed simpler to write something that just does what I want. All is well in the ElevateDB part of the job, the problem I've hit is in creating the shortcuts on the desktop and startup menu. I have burgled some code that runs OK, but the shortcuts never appear. I've posted the code under my signature. Single stepping through the code, I think the problem is in the variable LinkName. It ends up with a value something like this:- -------------------------------------------------- C:\Users\MyUserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup then a bunch of gobble-de-gook, followed by:- \MyProgramName.lnk -------------------------------------------------- I think that the problem lies in my lack of understanding how to handle arrays of characters. The Length of LinkName is 261 before the program name is added. MAX_PATH is 260 so an array[..MAX_PATH] would have 261 elements. So it looks like I have to trim off the garbage before adding the MyProgramName.lnk to LinkName OR not have it there to start with. Any pointers as to how to do this and get my shiny new ElevateDB app installed? TIA Cheers Jeff -- procedure MakeShortCut(aTarget: WideString; aFolder: Integer; // aFolder is e.g. CSIDL_STARTUP, CSIDL_DESKTOPDIRECTORY aShortCutName: WideString); var IObject: IUnknown; ISLink: IShellLink; IPFile: IPersistFile; PIDL: PItemIDList; InFolder: array [0 .. MAX_PATH] of Char; TargetName: string; LinkName: WideString; begin TargetName := aTarget; IObject := CreateComObject(CLSID_ShellLink); ISLink := IObject as IShellLink; IPFile := IObject as IPersistFile; with ISLink do begin SetPath(pChar(TargetName)); SetWorkingDirectory(pChar(ExtractFilePath(TargetName))); end; SHGetSpecialFolderLocation(0, aFolder, PIDL); SHGetPathFromIDList(PIDL, InFolder); SetString(LinkName, pChar(@InFolder[0]), Length(InFolder)); LinkName := LinkName + '\' + aShortCutName + '.lnk'; IPFile.Save(PWChar(LinkName), False); end; |
Wed, Oct 28 2015 4:18 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Jeff
I wanted to do something similar recently and found the code below - its very similar to yours and it seems to work here (D2006 & W7) - it may help {###############################################################################} {# COMPONENTS + TUTORIALS + SAMPLES + PROGRAMS + FORMS + TIPS + TRICKS #} {###############################################################################} {# {# Name.........: Create_Shortcuts {# Unit.........: Unit1.pas {# Released.....: 11-1-2009 20:29:14 {# Author.......: Nullified {# {###############################################################################} {# RATE MY SITE IF YOU THINK I DESERVE IT I WOULD APPRECIATE IT THANKS!! #} {###############################################################################} unit Shortcuts; interface uses Windows, SysUtils, Registry, ShlObj, ActiveX, ComObj, StdCtrls; procedure CreateShortcut(Executable, Parameters, LinkName, Location: string; uninstall: boolean); implementation procedure CreateShortcut(Executable, Parameters, LinkName, Location: string; uninstall: boolean); var LPUnknown: IUnknown; pShlLnk: IShellLink; pszFileName: IPersistFile; Dir: string; FullPath: WideString; R: TRegIniFile; begin LPUnknown := CreateComObject(CLSID_ShellLink); pShlLnk := LPUnknown as IShellLink; pszFileName := LPUnknown as IPersistFile; pShlLnk.SetPath(PChar(AnsiQuotedStr(Executable, '"'))); pShlLnk.SetArguments(PChar(AnsiQuotedStr(Parameters, '"'))); R := TRegIniFile.Create('Software\MicroSoft\Windows\CurrentVersion\Explorer'); try if Location = 'Start Menu' then Dir := R.ReadString('Shell Folders', 'Start Menu', '') else if Location = 'Desktop' then Dir := R.ReadString('Shell Folders', 'Desktop', '') else if Location = 'Startup' then Dir := R.ReadString('Shell Folders', 'Startup', ''); if Dir <> '' then begin FullPath := Dir + '\' + LinkName + '.lnk'; if uninstall then begin if FileExists(FullPath) then DeleteFile(FullPath); end else pszFileName.Save(PWChar(FullPath), False); end; finally R.Free; end; end; end. Roy Lambert |
Wed, Oct 28 2015 4:21 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Jeff
PS - I have no idea how it works - I just found the code and tried it without attempting to enhance my knowledge! Roy Lambert |
Wed, Oct 28 2015 2:56 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Jeff,
<< I'm writing an installer program because it seems like the obvious thing to do. I'd normally head for Inno Setup (or rather my colleague would!), but since the setup involves so much SQL to set up the databases, create users, roles, stores etc. It seemed simpler to write something that just does what I want. >> Just a quick note: we launch applications with a UI from Inno Setup during installation, and it works fine. So, you can still use Inno Setup, but just add a specific installer .exe to launch that will do the database-specific stuff and show a progress bar, etc. Then, just make sure to add an equivalent uninstaller .exe to undo anything that you want undone during the uninstaller. Tim Young Elevate Software www.elevatesoft.com |
Wed, Oct 28 2015 5:26 PM | Permanent Link |
Jeff Cook Aspect Systems Ltd | On 28/10/2015 9:21 p.m., Roy Lambert wrote:
> Jeff > > > PS - I have no idea how it works - I just found the code and tried it without attempting to enhance my knowledge! > > > Roy Lambert > Thanks Roy and Tim Roy I have no idea how it works either, but it works just fine with Delphi XE and Windows 8.1. Unlike the code that I found! Cheers Jeff |
Thu, Oct 29 2015 6:20 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Jeff
>I have no idea how it works either, Roy |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |