[DUG] Question about running an app. across a network

Jolyon Smith jsmith at deltics.co.nz
Thu Jul 9 07:59:32 NZST 2015


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20150709/85187765/attachment.html 


More information about the Delphi mailing list