Delphi

Delphi XE2 TZipFile: replace a file in zip archive

点点圈 提交于 2021-02-07 02:06:25
问题 I'd like to replace a file (= delete old and add new) in a zip archive with the Delphi XE2/XE3 standard System.Zip unit. But there are no replace/delete methods. Does anybody have an idea how it could be achieved without needing to extract all files and add them to a new archive? I have this code, but it adds the "document.txt" once more if it's already present: var ZipFile: TZipFile; SS: TStringStream; const ZipDocument = 'E:\document.zip'; begin ZipFile := TZipFile.Create; //Zipfile:

Delphi XE2 TZipFile: replace a file in zip archive

纵饮孤独 提交于 2021-02-07 02:06:23
问题 I'd like to replace a file (= delete old and add new) in a zip archive with the Delphi XE2/XE3 standard System.Zip unit. But there are no replace/delete methods. Does anybody have an idea how it could be achieved without needing to extract all files and add them to a new archive? I have this code, but it adds the "document.txt" once more if it's already present: var ZipFile: TZipFile; SS: TStringStream; const ZipDocument = 'E:\document.zip'; begin ZipFile := TZipFile.Create; //Zipfile:

Why is TImage rotating my image?

岁酱吖の 提交于 2021-02-07 01:59:28
问题 Writing a mobile application - it's pulling images from a secure website, and shown below (the first image) pulls incorrectly (notice web version vs mobile version), the second image shows correctly on the website, but Delphi TImage is rotating it for some reason and I can't figure out why. Rotate is set to 0 and "Fit" is set on the TImage component. Thoughts? 回答1: Jpeg and Tiff have Exif (Exchangeable image file format) metadata that specify image orientation (among other data). It's not

delphi - strip out all non standard text characers from string

此生再无相见时 提交于 2021-02-06 15:28:40
问题 I need to strip out all non standard text characers from a string. I need remove all non ascii and control characters (except line feeds/carriage returns). 回答1: Something like this should do: // For those who need a disclaimer: // This code is meant as a sample to show you how the basic check for non-ASCII characters goes // It will give low performance with long strings that are called often. // Use a TStringBuilder, or SetLength & Integer loop index to optimize. // If you need really

delphi - strip out all non standard text characers from string

五迷三道 提交于 2021-02-06 15:28:36
问题 I need to strip out all non standard text characers from a string. I need remove all non ascii and control characters (except line feeds/carriage returns). 回答1: Something like this should do: // For those who need a disclaimer: // This code is meant as a sample to show you how the basic check for non-ASCII characters goes // It will give low performance with long strings that are called often. // Use a TStringBuilder, or SetLength & Integer loop index to optimize. // If you need really

delphi - strip out all non standard text characers from string

两盒软妹~` 提交于 2021-02-06 15:27:28
问题 I need to strip out all non standard text characers from a string. I need remove all non ascii and control characters (except line feeds/carriage returns). 回答1: Something like this should do: // For those who need a disclaimer: // This code is meant as a sample to show you how the basic check for non-ASCII characters goes // It will give low performance with long strings that are called often. // Use a TStringBuilder, or SetLength & Integer loop index to optimize. // If you need really

delphi - strip out all non standard text characers from string

浪子不回头ぞ 提交于 2021-02-06 15:26:59
问题 I need to strip out all non standard text characers from a string. I need remove all non ascii and control characters (except line feeds/carriage returns). 回答1: Something like this should do: // For those who need a disclaimer: // This code is meant as a sample to show you how the basic check for non-ASCII characters goes // It will give low performance with long strings that are called often. // Use a TStringBuilder, or SetLength & Integer loop index to optimize. // If you need really

How can I get other processes' information with Delphi?

独自空忆成欢 提交于 2021-02-06 13:55:42
问题 I want to make a Task Manager program that displays this information: Image name memory usage PID How can I do this? 回答1: You don't need the J(WS)CL therefore, there is a simple WinAPI call that does almost all you want, and this is CreateToolhelp32Snapshot . To get a snapshot of all running processes, you have to call it as follows: var snapshot: THandle; begin snapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); Now you have a list of all running processes. You can navigate through

How to test the type of a generic interface?

坚强是说给别人听的谎言 提交于 2021-02-06 13:01:44
问题 I'm not sure if the title makes sense, but I hope you can understand my question with some code. Given the following code for a publish/subscribe framework. type IMessage = interface ['{B1794F44-F6EE-4E7B-849A-995F05897E1C}'] end; ISubscriber = interface ['{D655967E-90C6-4613-92C5-1E5B53619EE0}'] end; ISubscriberOf<T: IMessage> = interface(ISubscriber) procedure Consume(const message: T); end; TMessageService = class private FSubscribers: TList<ISubscriber>; public constructor Create;

How to test the type of a generic interface?

两盒软妹~` 提交于 2021-02-06 13:00:48
问题 I'm not sure if the title makes sense, but I hope you can understand my question with some code. Given the following code for a publish/subscribe framework. type IMessage = interface ['{B1794F44-F6EE-4E7B-849A-995F05897E1C}'] end; ISubscriber = interface ['{D655967E-90C6-4613-92C5-1E5B53619EE0}'] end; ISubscriberOf<T: IMessage> = interface(ISubscriber) procedure Consume(const message: T); end; TMessageService = class private FSubscribers: TList<ISubscriber>; public constructor Create;