Re: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default name

2021-06-18 Thread James Richters via fpc-pascal
>MAX_PATH itself seems to be an alias from system unit where it is defined accordingly to the operating system (260 on windows, 4096 on Linux, 1024 on BSD, Solaris and Darwin). >It's unlikely, but this way you can end up with the corruption of the byte right after the memory block DefaultFileName

Re: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default name

2021-06-18 Thread Jean SUZINEAU via fpc-pascal
I haven't seen your reply. Le 18/06/2021 à 23:50, James Richters via fpc-pascal a écrit : So now I have: TFileName.nMaxFile:= Length(DefaultFileName)+1; TFileName.lpstrFile:=Pchar(DefaultFileName); I need the +1 for the #0 at the end of the Pchar, and now it works fine, and I can have

Re: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default name

2021-06-18 Thread Jean SUZINEAU via fpc-pascal
I'm not familiar with GetSaveFileNameA, but usually for the size of a FileName  buffer I use the constant MAX_PATH which is defined in unit SysUtils. MAX_PATH itself seems to be an alias from system unit where it is defined accordingly to the operating system (260 on windows, 4096 on Linux,

Re: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default name

2021-06-18 Thread James Richters via fpc-pascal
I'm converting my AnsiString to a Pchar with TFileName.lpstrFile:=Pchar(DefaultFileName); But I didn't understand the meaning of TFileName.nMaxFile:=100; I thought it was the maximum number of files to display or something.. not the maximum number of characters in the file name. which it

Re: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default name

2021-06-18 Thread Alexander Grotewohl via fpc-pascal
The Windows API doesn't understand what an 'AnsiString' is and cannot resize it dynamically like FreePascal would do as it is used. You need to use something like buf: array[0..512] of char; TFileName.nMaxFile := sizeof(buf); But then you should also handle the possibility that the dir is

[fpc-pascal] GetSaveFileNameA limited to 100 characters in default name

2021-06-18 Thread James Richters via fpc-pascal
I'm using GetSaveFileNameA() in a windows console program to obtain a save-as directory and file name, I am passing sending it a default file name with: TFileName.lpstrFile:=Pchar(DefaultFileName); DefaultFileName is an AnsiString that contains a full path and filename. This all works fine

Re: [fpc-pascal] Will the size of an executable depend on the uses clause

2021-06-18 Thread Jean SUZINEAU via fpc-pascal
Ooops... little overflow bug My computer has reached 33 days of uptime today and with var     t, d, h, m, s: Integer; you switch to the negative side ... I got a display like : -8:-4:-52 Replacing with QWord solved the problem (I imagine DWord would just allow for something like 66 days) var

Re: [fpc-pascal] How to check if a network is available?

2021-06-18 Thread Jean SUZINEAU via fpc-pascal
Le 18/06/2021 à 17:07, Bo Berglund via fpc-pascal a écrit : I will need to check this in my connector class, the address to look for has to be a config item in my application so it can be modified if need be without rebuilding the app. Have to figure out how to: - Retrieve the output of the

Re: [fpc-pascal] How to check if a network is available?

2021-06-18 Thread Bo Berglund via fpc-pascal
On Fri, 18 Jun 2021 16:39:52 +0200, Jean SUZINEAU via fpc-pascal wrote: >I've never used open vpn, may be the 10.117 is defined in your >configuration file ? > >For the vpns I've used, the ip adressed were fixed. The tunnel IP address is defined server side and the route is pushed to the

Re: [fpc-pascal] How to check if a network is available?

2021-06-18 Thread Jean SUZINEAU via fpc-pascal
I've never used open vpn, may be the 10.117 is defined in your configuration file ? For the vpns I've used, the ip adressed were fixed. ( for route, you can type too something like "route print 10.117.*" ) ___ fpc-pascal maillist -

Re: [fpc-pascal] How to check if a network is available?

2021-06-18 Thread Bo Berglund via fpc-pascal
On Fri, 18 Jun 2021 15:00:18 +0200, Jean SUZINEAU via fpc-pascal wrote: >May be you can get some information with the "route" command . > >If you run "route print" in cmd command prompt, you can get information >on the different networks available. >

Re: [fpc-pascal] How to check if a network is available?

2021-06-18 Thread Tony Whyman via fpc-pascal
Yep, that's the golden rule in networking. The only way that you know that a bi-directional path is open is an end-to-end ping. Even then, you only know that it's open at the time the ping completed. If you are using TCP then you can always enable keepalive packets that effectively do the

Re: [fpc-pascal] How to check if a network is available?

2021-06-18 Thread Jean SUZINEAU via fpc-pascal
May be you can get some information with the "route" command . If you run "route print" in cmd command prompt, you can get information on the different networks available. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/route_ws2008 (I couldn't find the doc

Re: [fpc-pascal] How to check if a network is available?

2021-06-18 Thread James Richters via fpc-pascal
Do a Ping to an address on the network to see if it's connected? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] How to check if a network is available?

2021-06-18 Thread Bo Berglund via fpc-pascal
I would like to know how I can check if a remote network is available, i.e. if the VPN system has succeeded to connect the remote network. I need this in a class that connects an OpenVPN tunnel on demand and takes it down after use. Unfortunately openvpn-gui does not have an API call to do