Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Ftp get file doesn't work under One-click install?


1 reply to this topic

gronchi

gronchi
  • Members
  • 71 posts

Posted 25 July 2002 - 12:35

Hi to all,
I have a setup which can connect to an Ftp server and download some files during the installation process.
It works fine within a CDRom media.
Then I built an Internet media (one-click install setup) of the same project and I have FTP errors during the get file phase.

That is, the setup successful open the ftp session, (InternetOpenA and InternetConnectA Windows call) but it fails retrieving a file:

Code Sample

if(!FtpGetFileA(hFtp, sRemoteFileName, sLocalFileName, bFailIfExists, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)) then
  errNum = Err.LastDllError;
  errStr = FormatMessage (errNum);
  SprintfBox (SEVERE, "GetLastError partecipation", "Error code: %ld\nMessage text: %s", errNum, errStr);
endif


Well, as shown in .gif attached:
errNum = 1813
errStr = The specified resource type cannot be found in the image file. (ERROR_RESOURCE_TYPE_NOT_FOUND)

Anyone can help me to better understand where is the error?
What is the "resource type" not found? The remote or the local?
What is the "image file"?

Remarks
1.
By the way, I don't think FtpGetFileA produces this error (it's meaningless in my context), but Err.LastDllError when it tries to load the error string (for the unknown error produced by FtpGetFileA) and fails. Is it possible?

2.
Why can't I call GetLastError directly?
(ref. HOWTO: Getting the Return Code from the GetLastError API Document ID: Q105598).
I guess InstallShield zeroes the error code (using SetLastError()) in its
own functions, but I don't see why GetLastError() wouldn't work immediately
after FtpGetFileA().


Thanks.
Ciao, Giuseppe


Note:
Remember the fact: It works in CDRom media so the problem must reside in some difference between "CDRom-media approach" and "Internet-media approach"
Moreover, I'm testing the product so I'm sure there is not a banal error like:
-wrong file to retrieve (or absent or wrong-typed)
-wrong directory on the Ftp server (or absent)
-wrong local directory (or absent)
All these information are correct



gronchi

gronchi
  • Members
  • 71 posts

Posted 26 July 2002 - 07:24

SOLVED! (to whom it may concern)

No flag problem, no connection problem.

FtpGetFileA(hFtp, sRemoteFileName, sLocalFileName, bFailIfExists, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)

failed simply because it didn't find sLocalDir whereas:
sLocalFileName = sLocalDir ^ Filename

That is, running OnEnd event I had:
CDRomMedia --> sLocalDir present --> get file ok
InternetMedia (One-click install) sLocalDir absent --> get file ko

So I add (beginning of OnEnd event) following code:
Code Sample

// One-click install Fix!!!
nResult = Is (PATH_EXISTS, sLocalDir);
if (nResult = TRUE) then
  #ifdef DEBUG_SCRIPT
  SprintfBox (INFORMATION, "One-Click install FIX!!!", "%s is already present", sLocalDir);
  #endif
elseif (nResult = FALSE) then
  #ifdef DEBUG_SCRIPT
  SprintfBox (INFORMATION, "One-Click install FIX!!!", "%s is NOT present\nNow we create it!", sLocalDir);
  #endif
  if (CreateDir (sLocalDir) < 0) then
     #ifdef DEBUG_SCRIPT
     SprintfBox (INFORMATION, "One-Click install FIX!!!", "Unable to create %s\nThere should be problems...", sLocalDir);
     #endif
  endif;
else
  #ifdef DEBUG_SCRIPT
  SprintfBox (INFORMATION, "One-Click install FIX!!!", "Unable to determine if %s exists\nThere should be problems...", sLocalDir);
  #endif
endif;

and now it all works!

I don't know if this is a tipical One-Click install behavior or if I make a mistake building the same, anyway I hope this fix will help someone with similar problem.


Ciao, Giuseppe