Jump to content

Remy Lebeau

Members
  • Content Count

    2684
  • Joined

  • Last visited

  • Days Won

    113

Everything posted by Remy Lebeau

  1. Remy Lebeau

    Quality Portal going to be moved

    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.
  2. Remy Lebeau

    C++ Builder 11.3 / RenameFile() not working?

    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); }
  3. Remy Lebeau

    C++ Builder 11.3 / RenameFile() not working?

    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.
  4. Remy Lebeau

    Using same form for adding and editing data

    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.
  5. Remy Lebeau

    SMTP on Android

    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.
  6. 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.
  7. Remy Lebeau

    Readin Email with IMAP component

    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.
  8. Remy Lebeau

    Readin Email with IMAP component

    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.
  9. Remy Lebeau

    Newbie Question - VCL Object Rename

    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.
  10. 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>);
  11. Remy Lebeau

    F2047 Circular unit reference.

    You need to de-couple the classes so they don't refer to each other directly anymore. Use interfaces or events/callbacks instead.
  12. 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).
  13. Remy Lebeau

    Parallel.ForEach is really slow

    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.
  14. Remy Lebeau

    alignas

    alignas attribute not recognized in specifier-qualifier position of a member declaration https://github.com/llvm/llvm-project/issues/81472
  15. Remy Lebeau

    alignas

    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
  16. 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'.
  17. Remy Lebeau

    Delphi 11 POST AND GET HTTP

    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;
  18. Remy Lebeau

    alignas

    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.
  19. Remy Lebeau

    rease ... at ReturnAddress

    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}
  20. Remy Lebeau

    rease ... at ReturnAddress

    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.
  21. Remy Lebeau

    rease ... at ReturnAddress

    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.
  22. 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.
  23. 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);
  24. 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);
  25. Remy Lebeau

    NULL iterators in C++ Builder - 32 bit vs. 64 bit

    That is an implementation detail, don't rely on that.
×