-
Content Count
2684 -
Joined
-
Last visited
-
Days Won
113
Everything posted by Remy Lebeau
-
In the new system: https://qp.embarcadero.com Tickets from the old system have not been migrated over (yet?). Nope, but you can order by issue number, which are presumably sequential (or close to it). Nope. There are no "boards" in the new system. What I find funny is that I have filed 7 new tickets in the new system, but when I search for tickets "Where I am a participant", nothing shows up, but tickets "Created by me" do.
-
In C++: if (RenameFile(OldFileName_, NewFileName_)) lbControlText->Caption = _D("OK"); else lbOutput->Caption = _D("NewFileName_ : ") + NewFileName_ + _D("\nOldFileName_ : ") + OldFileName_ + _D("\nError : ") + IntToStr(GetLastError()); Alternatively use RaiseLastOSError() to throw an exception holding the error code: try { if (!RenameFile(OldFileName_, NewFileName_)) RaiseLastOSError(); lbControlText->Caption = _D("OK"); } catch (const EOSError& ex) { lbOutput->Caption = _D("NewFileName_ : ") + NewFileName_ + _D("\nOldFileName_ : ") + OldFileName_ + _D("\nError : ") + IntToStr(ex.ErrorCode); }
- 10 replies
-
- c++ builder
- 11.3
-
(and 1 more)
Tagged with:
-
RenameFile() does not raise an exception on failure, so your try..catch is useless. Are you sure FindFirst/FindNext() is even successful to begin with? You are not doing any error checking on FindFirst(). Did you debug to make sure OldFileName and NewFileName are what you are expecting? Also, you are using a file path into OneDrive, does OneDrive allow renaming files in this manner to begin with? Do you have the same problem with local files? Note that FindFirst() and FindNext() return the actual error code.
- 10 replies
-
- c++ builder
- 11.3
-
(and 1 more)
Tagged with:
-
You are editing a client, period. It shouldn't matter whether it is a new client or an existing client. So, using a simple flag (or other indicator telling you the client's state) to adjust the Form's behavior accordingly should suffice, no need to duplicate the work unnecessarily.
-
Sure. It's just a TCP connection to a server, like any other. Why would you think it's not possible? Indy 10 ships pre-installed with the IDE, and works on Android (mostly). It has TIdSMTP and TIdMessage components for sending emails. For TLS up to 1.2, there is TIdSSLIOHandlerSocketOpenSSL, and OpenSSL 1.0.2s libs for Android at https://github.com/IndySockets/OpenSSL-Binaries Or, you could simply use Android's built-in SSL/Socket class and implement the SMTP protocol yourself.
-
Changes in System.sysutils.pas were not reflecting in other unit in Delphi 11
Remy Lebeau replied to sp0987's topic in General Help
That would be true only if the record were being passed by value, but in this case it is being passed by explicit 'var' reference instead, so the size and location of the record doesn't matter. The GetLocalTime() API takes a pointer, which the 'var' satisfies. -
That will search for messages that are flagged as both UNSEEN AND RECENT. If you want to search for UNSEEN OR RECENT instead, you will have to add a 3rd array entry for the skOr search key: OR <search-key1> <search-key2> For example: SetLength(LEMailSearchInfo, 3); LEMailSearchInfo[0].SearchKey := skOr; LEMailSearchInfo[1].SearchKey := skUnseen; LEMailSearchInfo[2].SearchKey := skRecent; If you want to add a 3rd OR filter, you will need a 2nd skOk entry, eg: SetLength(LEMailSearchInfo, 5); LEMailSearchInfo[0].SearchKey := skOr; LEMailSearchInfo[1].SearchKey := skOr; LEMailSearchInfo[2].SearchKey := skUnseen; LEMailSearchInfo[3].SearchKey := skRecent; LEMailSearchInfo[4].SearchKey := skSubject; LEMailSearchInfo[4].Text := 'Sales'; // or: LEMailSearchInfo[4].SearchKey := skHeader; LEMailSearchInfo[4].FieldName := 'Subject'; LEMailSearchInfo[4].Text := 'Sales'; There isn't one, unfortunately. The (UID)SearchMailBox() methods are just a thin wrapper for the IMAP SEARCH command, so you'll have to read RFC 3501 Section 6.4.4 for how search semantics work. Also, https://stackoverflow.com/questions/12809709/ has some good information about using multiple ORs with IMAP search.
-
Call the TIdIMAP4.(UID)SearchMailBox() method, providing it with an array of desired filter criteria. It will populate the TIdIMAP4.MailBox.SearchResult list with numbers/UIDs of matching emails, which you can then download with any of the various TIdIMAP4.(UID)Retrieve...() methods.
-
If you simply rename the object manually, then you have to update all references manually. A search & replace may help, but is spotty and may have to be performed multiple times depending on how many files you need to update.. To rename everything automatically, you need to use the Refactor > Rename feature and let it update all of the references for you.
-
TRegistry: reading and writing REG_MULTI_SZ
Remy Lebeau replied to dummzeuch's topic in RTL and Delphi Object Pascal
Are you using an older version of Delphi? ReadMultiString() and WriteMultiString() methods were added in Delphi 12 Athens: function ReadMultiString(const Name: string): TArray<string>; procedure WriteMultiString(const Name: string; const Value: TArray<string>); -
F2047 Circular unit reference.
Remy Lebeau replied to dmitrybv's topic in RTL and Delphi Object Pascal
You need to de-couple the classes so they don't refer to each other directly anymore. Use interfaces or events/callbacks instead. -
RESTClient.OnNeedClientCertificate event does not execute
Remy Lebeau replied to Leszek's topic in Network, Cloud and Web
You are thinking of the SSLOptions.VerifyMode property instead, which has sslvrfPeer and sslvrfFailIfNoPeerCert flags. In any case... One reason the OnNeedClientCertificate event might not fire on Windows is if TRESTClient does not find any usable issuers in WinHTTP's client certificate issuer list: https://learn.microsoft.com/en-us/windows/win32/winhttp/ssl-in-winhttp#issuer-list-retrieval-for-ssl-client-authentication A 12175 error on the client side typically implies that there is a problem with the certificate that the server sent. Perhaps WinHTTP is not able to validate the servers certificate, because its issuing authority is not known to the client (ie, the server's signing certificate is not installed on the client). -
It is hard to diagnose this issue without knowing anything about your test setup, how many threads you are running, what the threads are doing, etc. But in general, simply throwing threads at a problem doesn't guarantee its speedup, if anything having too many threads can actually slow it down. So you have to make sure your thread usage is optimal for the task, has a good balance between work time and contexts switches, etc.
-
alignas attribute not recognized in specifier-qualifier position of a member declaration https://github.com/llvm/llvm-project/issues/81472
-
The classic compiler is not a C++11 compiler, but it does have a handful of C++11 features implemented (but not alignas). C++11 Features in the Classic Compiler http://docwiki.embarcadero.com/RADStudio/en/C%2B%2B11_Features_in_the_Classic_Compiler
-
How to exclude backup files with tilde character at end of file extension
Remy Lebeau replied to SteCam's topic in VCL
Unfortunately no, there is not. You will have to look at the actual extension in SearchRec.Name and ignore any files that are not exactly '.yml'. -
Yes, you need to use TIdMultipartFormDataStream for "multipart/form-data" requests, and TStringList for "application/x-www-form-urlencoded" requests. Your HTML uses "multipart/form-data". But, the TIdHTTP code you linked to is wrong for this task, because: It is sending form fields that don't exist in the HTML you showed. It is using a TStringStream to hold binary data. Use TMemoryStream instead. TIdMultipartFormDataStream.AddObject() is deprecated, use AddFormField() instead. It is setting the wrong ContentType. It should be set to 'multipart/form-data' instead, and don't set the ContentEncoding at all. Or better, simply don't set the ContentType at all, let Post() handle that. It is passing in the entire HTML <a> tag to TIdHTTP.Post(). It needs to pass in only the URL instead. Try something more like this: procedure TForm1.Button1Click(Sender: TObject); var PostData: TIdMultipartFormDataStream; rta: string; begin PostData := TIdMultipartFormDataStream.Create; try PostData.AddFormField('method', 'post'); PostData.AddFormField('key', '6969696969696969'); PostData.AddFile('file', 'C:\Users\migue\OneDrive\Desktop\form\Win32\Debug\captcha.png'); //IdHTTP1.Request.ContentType := 'multipart/form-data'; rta := IdHTTP1.Post('https://2captcha.com/in.php', PostData); finally PostData.Free; end; Memo1.Lines.Text := rta; end;
-
Which compiler(s) is your project using? alignas is supported only in the clang compilers, not in the classic compiler. What is the EXACT error message, verbatim? Also, FYI, you should be using alignas(T) instead. Or, since T is a template argument, use alignas(std::alignment_of<T>::value) or alignas(std::alignment_of_v<T>) instead.
-
In Indy, I use the return address in just 1 piece of code - the IndyRaiseOuterException() function. For XE2+, I use System.ReturnAddress(), and in pre-XE2 versions I use an inner function like how Delphi's SysUtils.Abort() does in XE: {$I IdStackFramesOff.inc} procedure IndyRaiseOuterException(AOuterException: Exception); procedure RaiseE(E: Exception; ReturnAddr: Pointer); begin raise E at ReturnAddr; end; asm // AOuterException is already in EAX... // MOV EAX, AOuterException MOV EDX, [ESP] JMP RaiseE end; {$I IdStackFramesOn.inc}
-
It's a shame they didn't simply update the AbstractErrorProc to accept the ReturnAddress as a parameter so it could be passed to the raise statement, eg: procedure _AbstractError; begin if Assigned(AbstractErrorProc) then AbstractErrorProc(ReturnAddress); // <-- RunErrorAt(210, ReturnAddress); end; ... procedure AbstractErrorHandler(AExceptAddr: Pointer); begin raise EAbstractError.CreateRes(@SAbstractError) at AExceptAddr; //^^^^^^^^^^^^^^ end; Like they did with RunErrorAt() in XE2. And also, as can be seen in other areas of System.pas, like the various _UnhandledException() implementations.
-
XE2. Prior to that, _AbstractError() used hand-written assembly code that didn't use a stack frame. In Delphi 5 (and probably earlier, I can't check), it looked like this: procedure _AbstractError; asm CMP AbstractErrorProc, 0 JE @@NoAbstErrProc CALL AbstractErrorProc @@NoAbstErrProc: MOV EAX,210 JMP _RunError end; In Delphi 6, some extra platforms were added: procedure _AbstractError; {$IFDEF PC_MAPPED_EXCEPTIONS} asm MOV EAX,210 JMP _RunError end; {$ELSE} {$IFDEF PIC} begin if Assigned(AbstractErrorProc) then AbstractErrorProc; _RunError(210); // loses return address end; {$ELSE} asm CMP AbstractErrorProc, 0 JE @@NoAbstErrProc CALL AbstractErrorProc @@NoAbstErrProc: MOV EAX,210 JMP _RunError end; {$ENDIF} {$ENDIF} Then somewhere between D7-D2006, the PC_MAPPED_EXCEPTIONS branch was dropped: procedure _AbstractError; {$IFDEF PIC} begin if Assigned(AbstractErrorProc) then AbstractErrorProc; _RunError(210); // loses return address end; {$ELSE} asm CMP AbstractErrorProc, 0 JE @@NoAbstErrProc CALL AbstractErrorProc @@NoAbstErrProc: MOV EAX,210 JMP _RunError end; {$ENDIF} Then in XE, the assembly code was restricted to just 386 CPUs and tweaked to include stack alignment, but still no stack frame: procedure _AbstractError; {$IF (not defined(CPU386)) or defined(PIC)} begin if Assigned(AbstractErrorProc) then AbstractErrorProc; _RunError(210); // loses return address end; {$ELSE} asm CMP AbstractErrorProc, 0 JE @@NoAbstErrProc {$IFDEF ALIGN_STACK} SUB ESP, 12 {$ENDIF ALIGN_STACK} CALL AbstractErrorProc {$IFDEF ALIGN_STACK} ADD ESP, 12 {$ENDIF ALIGN_STACK} @@NoAbstErrProc: MOV EAX,210 JMP _RunError end; {$IFEND} And then finally in XE2, the assembly code was eliminated completely: procedure _AbstractError; begin if Assigned(AbstractErrorProc) then AbstractErrorProc; RunErrorAt(210, ReturnAddress); end; Which is why it is now subject to the compiler's setting for stack frames when compiling System.pas.
-
What version of Delphi has the least amount of bugs throughout history?
Remy Lebeau replied to Al T's topic in Delphi IDE and APIs
For me, I spent 20-odd years of my professional career using C++Builder 6 exclusively. It held up quite well for what I needed, and I knew enough of its quirks to work through what didn't. Until about 7 years ago when I changed to a new company that doesn't use Delphi or C++Builder at all. But, for my personal work, XE2 was pretty rock solid. Now I'm using 12.1 and haven't had any problems with it yet, but I haven't pushed it yet either. -
Truncating precision of type double for GUI variables.
Remy Lebeau replied to BruceV's topic in General Help
Oh yeah, I keep forgetting about that one. Label1->Caption = FloatToStrF(DoubleVal, ffFixed, 10, 4); There is also FormatFloat(): Label1->Caption = FormatFloat(_D("0.0000"), DoubleVal);- 4 replies
-
- c++ builder
- wide string
-
(and 1 more)
Tagged with:
-
Truncating precision of type double for GUI variables.
Remy Lebeau replied to BruceV's topic in General Help
Alternatively, have a look at Sysutils::Format() Label1->Caption = Format(_D("%0.4f"), ARRAYOFCONST((DoubleVal))); or (Ansi|Unicode)String::sprintf() Label1->Caption = String().sprintf(_D("%0.4f"), DoubleVal);- 4 replies
-
- c++ builder
- wide string
-
(and 1 more)
Tagged with:
-
NULL iterators in C++ Builder - 32 bit vs. 64 bit
Remy Lebeau replied to Arvid P.'s topic in General Help
That is an implementation detail, don't rely on that.