AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Datei-Transfer mit DragAndDropComponentSuite
Thema durchsuchen
Ansicht
Themen-Optionen

Datei-Transfer mit DragAndDropComponentSuite

Ein Thema von harfes · begonnen am 13. Jul 2024 · letzter Beitrag vom 16. Jul 2024
 
Kas Ob.

Registriert seit: 3. Sep 2023
455 Beiträge
 
#9

AW: Datei-Transfer mit DragAndDropComponentSuite

  Alt 14. Jul 2024, 08:08
@himitsu

I am not sure if i do understand the problem, your software problem with drag and drop and outlook with lost/cutshort characters...

But looking at the attached project i see this strange lines
Code:
class function TForm25.GetLongName(Filename: string): string;
begin
  SetLength(Result, GetLongPathName(PChar(Filename), nil, 0) - 1);
  GetLongPathName(PChar(Filename), PChar(Result), Length(Result) + 1);
end;

class function TForm25.GetShortName(Filename: string): string;
begin
  SetLength(Result, GetShortPathName(PChar(Filename), nil, 0) - 1);
  GetShortPathName(PChar(Filename), PChar(Result), Length(Result) + 1);
end;
Why the "-1" ?
And more importantly :
Why you are not trimming after the second call based on the GetxxxxPathName result ?

My suggestion is to fix that then repeat your test with the customers:
The flow for this type of API use, should always be one call to decide the length, then allocate then call again then trim, don't cut corners, and never trust the first call for the length as it might change between the two calls.

When in doubt for Unicode and UTF8 for the real length in bytes against chars (WideChar, UTF8Char, UTF16Char....) change the allocate step mentioned above to RequiredLength*4, this will be removed with the last trim, in other words trade "little more work and allocation" against "will work always", also this will remove the need to keep tracking of the different APIs which some do return the 0 terminated and some doesn't, so you can with extra big allocated put the null char your self before the trim, and either keep it or remove it, based on the use case.
Kas
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:39 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz