Indy 10 Delphi FTP Client Demo Error - delphi

I am new to Delphi and wanted to try breaking down a demo to understand the it's structure.
I am trying to get the Indy 10 Delphi FTP Client demo to run on Delphi XE2.
Whenever I run the downloaded code, I enter the FTP URL, Username, Password etc and when the FTP connects this error appears:
raised exception class $C00000005 with message 'access violation at
0x0018f90e: write of address 0x0000000'
Which I assume it means it's pointing at a null?
The debugging tool simple points at this line..
ChangeFTPDir(Sites[cbFTPAddress.ItemIndex].RootDir);
What would be the best way of removing this error (try/catch) or is there a working sample of a Delphi FTP procedure that I could have a look at?
Thanks for your time in advance,
Sophie
The procedure is as below:
procedure TfrmMain.ChangeFTPDir(NewDir: String);
begin
FLastDirStack.Add(FTP.RetrieveCurrentDir);
FTP.ChangeDir(NewDir);
DisplayFTP;
end;
I assume that the site array does contain details as the ftp does connect to the name of the stored ftp site before the error appears...

Did you use IdAllFTPListParsers ? Try it.

Related

Changes to Indy10 between Delphi 2007 and Delphi 11.1 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 months ago.
Improve this question
I have some really old code that was compiled with the version of Indy10 that was included in Delphi 2007. Having recompiled this in Delphi 11.1 the TCP Clients that should connect to the server application no longer do so. I'm trying to connect to the server using 127.0.0.1 on port 50000. Instead I get "connection timeout" or "socket operation on a non-socket" errors.
Is there any documentation anywhere that details what has changed between Indy10 in Delphi 2007 and Delphi 11.1? All the links on the Indy Project website are broken so I haven't found anything there. According to the Log at the start of IdTCPClient.pas there are no changes between the two however a quick file comparison reveals quite a few changes including the change of Port value from Integer to TIdPort. I've recompiled our server application in Delph11.1 and it will accept connections from older clients compiled in Delphi 2007 but not from new clients (hence I suspect changes IdTCPClient may be giving me issues). Thanks in advance for any help.
The code that tries to open the connection is below;
function TClientServer.Connect(SuppressMsg : Boolean) : Boolean;
begin
Result := False;
if (FRunning = False) and (Connecting = False) then
begin
try
TCPClient.ConnectTimeout := FConnectTimeout;
Connecting := True;
if assigned(TCPClient.IOHandler) then
begin
TCPClient.IOHandler.ConnectTimeout := FConnectTimeout;
TCPClient.IOHandler.MaxLineAction := maSplit;
end;
TCPClient.Connect;
Result := True;
except on E : Exception do
begin
Connecting := false;
if SuppressMsg = False then
begin
{ Look at cycling through the servers in the FCoreServer list }
{ until we manage to connect to one. Perhaps we need to prompt }
{ the user to select the machine to connect to ? }
ShowMessage('Failed to connect to the core server !' + #13#10#10 +
'Please ensure server is running at address ' +
TCPClient.Host + ' (' + IntToStr(TCPClient.Port) + ')' + #13#10 + E.Message );
end;
end;
end;
end;
end;
Having recompiled this in Delphi 11.1 the TCP Clients that should connect to the server application no longer do so. I'm trying to connect to the server using 127.0.0.1 on port 50000. Instead I get "connection timeout" or "socket operation on a non-socket" errors.
I know for a fact that Indy works on localhost, so the problem has to be with either your setup or your environment. But you did not provide any details about either one.
Is there any documentation anywhere that details what has changed between Indy10 in Delphi 2007 and Delphi 11.1?
There is Indy's blog that describes some of the more user-facing changes that have been made over time. But for more detailed changes, you would have to look at the source code change history in Indy's GitHub repo.
All the links on the Indy Project website are broken
Known issue: https://www.indyproject.org/2021/02/10/links-to-old-indy-website-pages-are-currently-broken/ I just haven't had any time to fix it yet.
According to the Log at the start of IdTCPClient.pas there are no changes between the two
The change logs that are stored in the source files themselves are very old. They are leftovers from when Indy used TeamCoherence as its VCS many years ago. When Indy switched from TC to SVN (and then later to GitHub), new change logs are no longer stored in the source file themselves. I've been wanting to either remove the old logs, or put a final "these are old" comment in them, for a long time.
I've recompiled our server application in Delph11.1 and it will accept connections from older clients compiled in Delphi 2007 but not from new clients (hence I suspect changes IdTCPClient may be giving me issues).
I am not aware of any changes that would be breaking the connection. It should be working fine. But, without seeing your setup and environment, there is no way to know what could possibly be preventing the connection.
I finally found the problem; the changes to Indy10 are a red herring. My project was using FastMM in several units and for some strange reason when I commented out all instances it worked! The client now happily connects to the server. #RemyLebeau - thanks so much for all your help with this and quite a few other questions I've posted over the last few months.

Datasnap Delphi XE7 - ApplyUpdates(0) issue

I have a datasnap server app developed originally with XE5 that was working fine with a client app on a mobile tablet accessing a Firebird database on a server. I have recompiled the code with XE7. The only change I had to make to the code to compile without any errors was to add DataSnap.DSProviderDataModuleAdapter to the uses of the methods unit. Have replaced the server app on the server (stop service/uninstall/reinstall/start service) and now I can no longer insert/update records in the database on the server. Whenever I reach the line of code to ApplyUpdates(0) I get the following error:
Remote Error: Access violation at address 0093CB3F in module Snackerservice.exe. Read of address 00000000.
Retrieving data from the database to display on the tablet is not a problem so the connection is working.
If I change the server app back to the one developed under XE5......all works fine again. The other strange thing is that there are no problems with the XE7 compiled app when using 'localhost' to access a copy of the database on my development machine......only when accessing through an IP connection to a server.
Can someone please help me solve this frustrating problem.
Bill Zwirs
To hopefully make it a little clearer, here is a bit of code that causes the issue:
iLic := ServerMethodsClient.Get_Licences;
iDev := ServerMethodsClient.Get_NumDevices;
if (iDev < iLic) then
begin
iDevID := ServerMethodsClient.Get_NewDevID;
MobClientDM.DevicesClient.Open;
MobClientDM.DevicesClient.Insert;
MobClientDM.DevicesClientDEVID.AsInteger:= iDevID;
MobClientDM.DevicesClientMACADDRESS.AsString := sMacAddress;
MobClientDM.DevicesClient.Post;
if (MobClientDM.DevicesClient.ChangeCount > 0) then
MobClientDM.DevicesClient.ApplyUpdates(0); ....................Error occurs here
end;
Problem solved at last.
When I installed the server app on the server I also added Midas.dll to the directory which worked fine until I compiled with XE7. So I have now included MidasLib in the uses clause of the server app and removed the Midas.dll file from the install directory. Compiled and installed and all works good again.
Hope this helps others who might have a similar problem.
Bill Zwirs

Generate PDF using QuickReport from a Windows Service in Delphi

I'm writing a windows service using Delphi XE3. The service is going to read from a database, generate a pdf using quickreport 5.05.1.
I plan to generate the pdf using TQRPDFDocumentFilter.
Everything works fine in a normal VCL application, but when I implement it in a windows service the service hangs (without any exceptions) when I do a QuickRep.Prepare.
I have read that it is possible to use QuickReport in a windows service, but I do not know how. Any suggestions?
Where is the code:
procedure foo
var
pdfFilter: TQRPDFDocumentFilter;
begin
with TForm2.Create(Self) do
begin
ClientDataSet1.Open;
QuickRep1.Prepare;
pdfFilter := TQRPDFDocumentFilter.Create(GetApplicationFolder() + 'test.pdf');
try
QuickRep1.QRPrinter.ExportToFilter(pdfFilter);
finally
pdfFilter.Free;
ClientDataSet1.Close;
end;
end;
end;
Edit:
I have also tried turning off "show progress" on the QuickReport as suggested in another thread.
Writing some code to catch an exception reveals that it indeed throws one. The message is "There is no default printer currently selected".
So this leads me to believe that the local system user that the service is running under does not have any printers installed and that this is the problem.
I have resolved a similar problem (printing to a shared network printer from a Java server running as a Windows service) with these steps:
log on as the user who will run the service
install the printer
IIRC with Delphi applications, the printer name is not case sensitive (with Java it is).

Downloading fails from ftp server using TMS Webcopy software in Delphi xe3

Hi i am trying to use TMS software to download a file. But cannot seem to get the file to download.
i use the following code, and have written in an exception handler which keeps telling me that the URL cannot be found. Any help would be appreciated.
main.WebCopy1.Items.Clear;
with main.WebCopy1.Items.Add do
begin
FTPHost :=fHost;
FTPUserID := fusername;
FTPPassword := fPass;
URL := '\Setup\libmysql.dll';
Protocol := wpFTP;
CopyNewerOnly := true;
TargetDir := 'c:\Program Files\myfolder\';
end;
main.WebCopy1.Execute;
May i just add, i just tested the same code and url in another project that i had written and it worked.
Thank You
Things I would try:
use the debugger and check the code which connects and sends the HTTP request
check your HTTP server log file to see which resource has been requested
use a HTTP proxy (Fiddler) to intercept and analyze the HTTP traffic between the Delphi application and your HTTP server
extract the relevant part of the two projects, then diff their sources
(both with the working and the non-working application).
Sorry guys i found the problem. The connection was not set to passive.
I checked on the server and could not find that any connection was being made to the ftp account, and realized that the problem was not the path, it was the connection.
So i checked and saw the connection was set to passive, changed it an vualla, it worked.
So Now We know, For it to work passive must be set to true.
Thanks alot anyway guys

Why does GetActiveObject fail to detect running instance of Outlook?

I am facing an issue in my windows7 32bit Pc(on i3).I have Outlook 2010 and Delphi 7 on it.
I am using following code to detect Outlook is running or not.
ClassID := ProgIDToClassID(ClassName);
Result := (GetActiveObject(ClassID, nil, Unknown) = S_OK);
This fails, ie, result become false and yet in other PCs this working fine.
The error I'm getting is MK_E_Unavailable.
Update:
May be it just happening with me only.
procedure TForm1.Button1Click(Sender: TObject);
function IsObjectActive(ClassName: string): Boolean;
var
ClassID: TCLSID;
Unknown: IUnknown;
begin
try
ClassID := ProgIDToClassID(ClassName);
Result := (GetActiveObject(ClassID, nil, Unknown) =S_OK );
except
Result := False;
end;
end;
begin
if IsObjectActive('Outlook.Application') Then
ShowMessage('OutLook is there.')
else
ShowMessage('OutLook is not there.')
end;
Plz note OL is running and
When I am running the created exe, I am getting message "OutLook is there".
when I am running from Delphi IDE, I am getting Message 'OutLook is not there.'
This happens always, I am using Delphi 7 on Windows 7, running with Run as Admin. Kindly tell me why this happening and how can I fix this.
What's the issue of Delphi 7 on Windows 7.
Please suggest.
Here's the entry for GetActiveObject.
http://msdn.microsoft.com/en-us/library/a276e30c-6a7f-4cde-9639-21a9f5170b62%28VS.85%29
If you want to decode the error, you need to find out what the HResult means.
Wikipedia has a link to a ERR.EXE utility from MS that will translate the HResult code into an error description. For COM HResults see: http://matthewbass.com/2005/11/15/decoding-com-hresult-error-codes/.
note the download link in the article is broken, here's a working link: http://www.softlookup.com/display.asp?id=7113
Once you know what the error is, update the question.
If you want to know whether a process is running without using OLE, see: How to check if a process is running using Delphi?
Another option might to use FindWindowEx to check for Outlook 2010 specific windows.
You can use WinID (a spy++ clone) to see the windows used by Outlook 2010.
I was facing the same issue and I found the solution.
It's simple, If Outlook is already running, it MUST have the same rights as the process that is trying to use it.
In simple words, if you are running Outlook with admin rights, you must execute your app with admin rights.
Your problem must be that you are running Outlook without admin rights, and Delphi IDE with admin rights. So when you are launching your app from within IDE, the rights doesn't match, and you get the error. This is why when running your app outside the IDE it works as expected. Because outside IDE your app runs without admin rights.
Try to match the rights. This is something to take into account for the end user environment too.
Also, the UAC under Windows Vista and later is known to cause multiple issues with these type of things. If everything else fails, disable UAC (User Account Control, you will find it under your account options) and see what happens.
try to use rctrl_renwnd32
try this:
(FindWindow('rctrl_renwnd32', nil) <> 0)
http://users.skynet.be/am044448/Programmeren/VBA/vba_class_names.htm

Resources