@@ -305,7 +305,7 @@ TWIADevice = class(TNoRefCountObject, IWiaTransferCallback)
305305 function Download (APath, AFileName, AExt: String): Integer; overload;
306306 function Download (APath, AFileName, AExt: String; AFormat: TWIAImageFormat): Integer; overload;
307307 function Download (APath, AFileName, AExt: String; AFormat: TWIAImageFormat;
308- var DownloadedFiles: TStringArray): Integer; overload;
308+ var DownloadedFiles: TStringArray; UseRelativePath: Boolean=False ): Integer; overload;
309309 (* // In Wia 2 the user must specify what to download from the feeder using the ADocHandling parameter,
310310 // the SettingsForm store DocHandling in Params so the user can use here.
311311 function Download(APath, AFileName, AExt: String; ADocHandling: TWIADocumentHandlingSet=[]): Integer; overload;
@@ -318,7 +318,7 @@ TWIADevice = class(TNoRefCountObject, IWiaTransferCallback)
318318 // The system dialog works at Device level, so the selected item is ignored
319319 function DownloadNativeUI (hwndParent: HWND; useSystemUI: Boolean;
320320 APath, AFileName: String;
321- var DownloadedFiles: TStringArray): Integer;
321+ var DownloadedFiles: TStringArray; UseRelativePath: Boolean=False ): Integer;
322322
323323 // Get Current Property Value and it's type given the ID
324324 function GetProperty (APropId: PROPID; var propType: TVarType;
@@ -724,6 +724,13 @@ procedure VersionStrToInt(const s: String; var Ver, VerSub: Integer);
724724 end ;
725725end ;
726726
727+ function FullPathToRelativePath (const ABasePath: String; var APath: String): Boolean;
728+ begin
729+ Result:= (Pos(ABasePath, APath) = 1 );
730+ if Result
731+ then APath:= ' .' +DirectorySeparator+Copy(APath, Length(ABasePath)-1 , MaxInt);
732+ end ;
733+
727734function WIAItemTypes (pItemType: LONG): TWIAItemTypes;
728735begin
729736 Result :=[];
@@ -1298,7 +1305,7 @@ function TWIADevice.Download(APath, AFileName, AExt: String; AFormat: TWIAImageF
12981305end ;
12991306
13001307function TWIADevice.Download (APath, AFileName, AExt: String; AFormat: TWIAImageFormat;
1301- var DownloadedFiles: TStringArray): Integer;
1308+ var DownloadedFiles: TStringArray; UseRelativePath: Boolean ): Integer;
13021309var
13031310 i: Integer;
13041311
@@ -1312,16 +1319,24 @@ function TWIADevice.Download(APath, AFileName, AExt: String; AFormat: TWIAImageF
13121319 if (Result > 0 ) then
13131320 begin
13141321 SetLength(DownloadedFiles, Result);
1315- DownloadedFiles[0 ]:= rDownload_Path+rDownload_FileName+rDownload_Ext;
1316- for i:=1 to Result-1 do
1317- DownloadedFiles[i]:= rDownload_Path+rDownload_FileName+
1318- ' -' +IntToStr(i)+rDownload_Ext;
1322+
1323+ if UseRelativePath
1324+ then begin
1325+ DownloadedFiles[0 ]:= rDownload_FileName+rDownload_Ext;
1326+ for i:=1 to Result-1 do
1327+ DownloadedFiles[i]:= rDownload_FileName+' -' +IntToStr(i)+rDownload_Ext;
1328+ end
1329+ else begin
1330+ DownloadedFiles[0 ]:= rDownload_Path+rDownload_FileName+rDownload_Ext;
1331+ for i:=1 to Result-1 do
1332+ DownloadedFiles[i]:= rDownload_Path+rDownload_FileName+' -' +IntToStr(i)+rDownload_Ext;
1333+ end ;
13191334 end ;
13201335 end ;
13211336end ;
13221337
13231338function TWIADevice.DownloadNativeUI (hwndParent: HWND; useSystemUI: Boolean; APath, AFileName: String;
1324- var DownloadedFiles: TStringArray): Integer;
1339+ var DownloadedFiles: TStringArray; UseRelativePath: Boolean ): Integer;
13251340var
13261341 dlgFlags: LONG;
13271342 i: Integer;
@@ -1369,6 +1384,10 @@ function TWIADevice.DownloadNativeUI(hwndParent: HWND; useSystemUI: Boolean; APa
13691384 for i:=0 to rDownload_Count-1 do
13701385 begin
13711386 DownloadedFiles[i]:= filePaths^[i];
1387+
1388+ if UseRelativePath
1389+ then FullPathToRelativePath(rDownload_Path, DownloadedFiles[i]);
1390+
13721391 SysFreeString(filePaths^[i]);
13731392 end ;
13741393
0 commit comments