[DUG] Question about running an app. across a network
Jolyon Smith
jsmith at deltics.co.nz
Thu Jul 9 08:49:49 NZST 2015
Re updating EXE's, this is do-able even without that flag.
The trick there is that the file system won't allow you to delete a file
that is in use, but it will allow you to *rename* it. So:
- Rename current file APP.EXE -> APP.EXE.OLD
- Place new APP.EXE in location
- Delete APP.EXE.OLD
When you delete a file in use the file isn't actually deleted but is only
marked for deletion once all current handles are closed. Renaming the file
is OK since anyone still running the old copy is unaffected (their file
handle is attached to the *file itself*, not the file *name*) until they
quit the app and restart, at which point they seamlessly pick up the new
version.
You've already worked around the problem with that PE flag for EXE's on a
network, but this same technique can be useful in locally installed
applications e.g. auto-updating app EXE's.
On 9 July 2015 at 08:32, Jeremy Coulter <jscoulter at gmail.com> wrote:
> Thanks Joylon. Yip already have that flag set.It also enables the Exe on
> the server to be updated without having to get users to close down their
> versions running on client machines.
> I think the APPData (common) will be a better location given I expect
> there may be multiple users on some machines.
> I'll give that a poke and see howit works. Shouldnt be hard to replace the
> instances of (ExtractFilepath(Paramstr(0))) with a variable to APPData
> Common :-)
>
> Thanks, guys.
>
>
> On Thu, Jul 9, 2015 at 7:59 AM, Jolyon Smith <jsmith at deltics.co.nz> wrote:
>
>> As David says, access the INI file on the client is a simple matter of
>> deciding on a safe, reliable location (i.e. follow Windows guidelines for
>> such configuration files). However for a configuration file I would
>> suggest the use of AppData folder, rather than Documents.
>>
>> Use SHGetFolderPath() (from SHFolder unit) using CSIDL_APPDATA (per user
>> settings) or CSIDL_COMMON_APPDATA (shared/system wide). If you do decide
>> to use the user documents folder then use CSIDL_PERSONAL instead.
>>
>> NOTE: This is for supporting Windows versions pre-dating Vista. If you
>> don't need to worry about that and can use Vista+ specific API's then you
>> should use the newer Known Folders API instead (
>> https://msdn.microsoft.com/en-us/library/windows/desktop/bb776911(v=vs.85).aspx
>> ).
>>
>>
>>
>> Something else to bear in mind with this sort of approach is that if your
>> user suffers even a micro-outage to the file server where the application
>> EXE is located, this can result in a C0000006 exception if/when Windows
>> tries to page the EXE during that outage. Your app is then unrecoverable
>> from that point and requires a restart which may not otherwise be necessary
>> once the outage is restored. The outages involved can be so brief that the
>> user is otherwise unaware but can be catastrophic for applications running
>> from net drives.
>>
>> To avoid this you can mark the EXE with a PE header attribute that
>> directs Windows to load the entire EXE into the workstation swapfile at
>> launch, avoiding the need to load any further pages over the network. If
>> you are using Delphi 7 or later (NOT XE7, just plain old 7) you can achieve
>> this by adding a SETPEFLAGS directive to your application (typically in the
>> DPR):
>>
>> {$SETPEFLAGS IMAGE_FILE_NET_RUN_FROM_SWAP}
>>
>> NOTE: You will need to add this AFTER the uses clause, and you will need
>> the Windows unit in that uses clause since this directive sets attributes
>> based on numeric values of constants and IMAGE_FILE_NET_RUN_FROM_SWAP is
>> defined in the Windows unit.
>>
>>
>>
>> On 8 July 2015 at 21:58, Jeremy Coulter <jscoulter at gmail.com> wrote:
>>
>>> Hi All.
>>> I have an app that I will be running from a server location. However, I
>>> want the app. to read an ini file that is located in a folder on a client
>>> machine.
>>> A Shortcut to the app on the server and the ini file will live in a
>>> folder on the client machine, but I cant work out how to get the app, when
>>> its run via the shortcut, to read the ini file on the client machine.
>>> Anyone know how to go about doing this?
>>> I have thought about dropping the INI and transferring the settings to a
>>> database with a row for each machine that connects, but before I get that
>>> carried away, I just wanted to see if someone had any ideas to do the above
>>> with the ini file.
>>> The reason I want an ini for each computer is about settings. Not all
>>> machines have the same settings etc.
>>>
>>> Thanks, Jeremy
>>>
>>> _______________________________________________
>>> NZ Borland Developers Group - Delphi mailing list
>>> Post: delphi at listserver.123.net.nz
>>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>>> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
>>> Subject: unsubscribe
>>>
>>
>>
>> _______________________________________________
>> NZ Borland Developers Group - Delphi mailing list
>> Post: delphi at listserver.123.net.nz
>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
>> Subject: unsubscribe
>>
>
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20150709/f5b91288/attachment.html
More information about the Delphi
mailing list