delphi-2010

Thread-safe in delphi

有些话、适合烂在心里 提交于 2019-11-26 20:45:40
问题 I have to modify and change some visual components in a thread and as you know it's not safe to doing this. My question is how to write a completely thread-safe code? It is possible? if it is then can you please give me a simple example? my code that is not threadsafe: type tMyWorkerThread = class(TThread) public procedure Execute; override; end; var Form1: TForm1; implementation {$R *.dfm} procedure tMyWorkerThread.Execute; begin //codes //working with visual components end; procedure TForm1

Binary to Base64 (Delphi)

筅森魡賤 提交于 2019-11-26 20:43:19
how can i get content of an exe file and convert it into Base64 encoding ? Edit I use D2010 and i want to know how is it possible exactly ? open an exe file convert its content into base64 Uwe Raabe In Delphi 2009/2010/XE there is unit EncdDecd.pas ( Soap.EncdDecd.pas for Delphi XE2) containing the functions EncodeBase64 and DecodeBase64 . You can load the exe file into a memorystream and then call EncodeBase64. function EncodeFile(const FileName: string): AnsiString; var stream: TMemoryStream; begin stream := TMemoryStream.Create; try stream.LoadFromFile(Filename); result := EncodeBase64

Delphi pre-build event not executing BEFORE compile

試著忘記壹切 提交于 2019-11-26 20:26:48
问题 I'm busy automating our builds to include the svn revision number. We're using Delphi 2010. I added a pre-build event calling a batch file that injects the the svn revision number (read from the entries file in the .svn directory) and a specified version number into aVersionInfo.rc that is compiled with my project. The pre-build event looks like this: call SetVersionInfo.bat 6 5 4 ...and the batch file (hope someone finds this useful)... @ECHO OFF SETLOCAL setLocal EnableDelayedExpansion SET

Selecting a directory with TOpenDialog

﹥>﹥吖頭↗ 提交于 2019-11-26 19:22:46
问题 I'd really like to know the various ways I could select a directory with the TOpenDialog, whether it be downloading a new component or using what is provided by Delphi, but preferably using what is provided by Delphi. Prior to this, I have been using the SelectDirectory command but I think it'd be a difficulty for the users of my program to look for the specified directory. I think the SelectDirectory is 'weak' because it can be a long process when searching for the directory you want. Say

TThread.resume is deprecated in Delphi-2010 what should be used in place?

為{幸葍}努か 提交于 2019-11-26 18:08:30
问题 In my multithread application I use TThread.suspend and TThread.resume Since moving my application to Delphi 2010 I get the following warring message [DCC Warning] xxx.pas(277): W1000 Symbol ‘Resume’ is deprecated If Resume is deprecated what should be used in place? EDIT 1: I use the Resume command to start the thread - as it is Created with 'CreateSuspended' set to True and Suspend before I terminate the thread. EDIT 2: Here is a link the delphi 2010 manual 回答1: Charles if do you read the

How to split string by a multi-character delimiter?

a 夏天 提交于 2019-11-26 17:23:09
问题 Is there a Delphi function to split string by a multi-character delimiter rather than a single character ? For instance when I'd use that function this way: SplitString('Whale<->Mammal<->Ocean', '<->') I would get a result of these 3 strings: 'Whale', 'Mammal', 'Ocean' Is there such function in Delphi for this ? 回答1: There is another quite simple solution using TStringList. Change the LineBreak: procedure TForm208.Button1Click(Sender: TObject); var lst: TStringList; begin lst := TStringList

How to make MessageDlg centered on owner form

空扰寡人 提交于 2019-11-26 16:32:10
问题 I'd like that MessageDlg appear centered on its parent form. Any suggestions on how to accomplish this in Delphi 2010? I found the code below here: http://delphi.about.com/od/formsdialogs/l/aa010304a.htm but it's not working for me. The pop-up still is not centered on the owner form. (It's not clear to me how the method would actually know the owner form...) function TForm1.MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Integer): Integer; begin with

Delphi 2010: How to save a whole record to a file?

ⅰ亾dé卋堺 提交于 2019-11-26 16:28:44
I have defined a record which has lots of fields with different types (integer, real , string, ... plus dynamic arrays in terms of "array of ..."). I want to save it as a whole to a file and then be able to load it back to my program. I don't want to go through saving each field's value individually. The file type (binary or ascii or ...) is not important as long Delphi could read it back to a record. Do you have any suggestions? You can load and save the memory of a record directly to and from a stream, as long as you don't use dynamic arrays. So if you use strings, you need to make them

Free Encryption library for Delphi [closed]

柔情痞子 提交于 2019-11-26 12:58:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I\'m looking for a free and up to date encryption library for Delphi 2010 that implements RSA and AES (Rijndael). I want a free library because I plan to write and publish some sample code that will use it. A Delphi 2010 version of TurboPower LockBox has been posted to the SongBeamer site, that implements both

Binary to Base64 (Delphi)

南楼画角 提交于 2019-11-26 09:02:52
问题 how can i get content of an exe file and convert it into Base64 encoding ? Edit I use D2010 and i want to know how is it possible exactly ? open an exe file convert its content into base64 回答1: In Delphi 2009/2010/XE there is unit EncdDecd.pas ( Soap.EncdDecd.pas for Delphi XE2) containing the functions EncodeBase64 and DecodeBase64 . You can load the exe file into a memorystream and then call EncodeBase64. function EncodeFile(const FileName: string): AnsiString; var stream: TMemoryStream;