Jump to content

Remy Lebeau

Members
  • Content Count

    2684
  • Joined

  • Last visited

  • Days Won

    113

Everything posted by Remy Lebeau

  1. The C# code is writing the base64 content as-is to the socket, it is not encoding the base64 to the "x-www-form-urlencoded" format. Base64 can use '+' and '=' characters, which are reserved in "x-www-form-urlencoded" and must be encoded as "%2B" and "%3D" in application data, respectively. The receiver must decode them back into '+' and '=' characters, respectively, before then decoding the base64. Per the HTML standards, which define the "x-www-form-urlencoded" format: HTML 4.01 Section 17.13.4 ("Form content types"): HTML 5 Section 4.10.16.4 ("URL-encoded form data"): In other words, in a "x-www-form-urlencoded" submission, any non-syntax characters (ie, field separators '=' and '&') that are not in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*-._" should be encoded in %HH format, except for space characters which are encoded as '+' instead. That means even your "DevApp" field should be transmitted as "C%23" instead of as "C#".
  2. Remy Lebeau

    Code using TIdIMAP4 driving me mad !!

    Can you please provide the actual configuration you are expected to use? This does not sound like a standard setup.
  3. Remy Lebeau

    Breakpoints do not work.

    That is not the vibe I get when reading his question. He likely just wants to debug his own source code, not Delphi's framework source code.
  4. Remy Lebeau

    TIdSNTP still providing daylight saving time

    Yes, and has been for several years now: https://www.indyproject.org/2019/11/28/indy-svn-retiring-long-live-github/ Yes, it will include an updated snapshot of Indy from about a month ago. However, you don't have to upgrade Delphi just to get a new Indy version. You can install the latest GitHub repo version manually: https://github.com/IndySockets/Indy/wiki/Updating-Indy
  5. Remy Lebeau

    Form still on display when property Visible = false

    This code is taken out of context, and hard to diagnose as-is. You are going to have to show a more complete example. But if I had to guess, you are likely seeing a completely different Form object onscreen than the one that is processing this code.
  6. Remy Lebeau

    Breakpoints do not work.

    Are you sure you are actually running in debug mode?
  7. Remy Lebeau

    Code using TIdIMAP4 driving me mad !!

    Are you sure you are supposed to be using implicit TLS on port 143, and not explicit TLS instead? Implicit TLS sends the TLS handshake as soon as the TCP connection is established, before exchanging any other data, thus all protocol data is encrypted. Explicit TLS (aka STARTTLS) sends the TLS handshake after first establishing an unencrypted TCP connection and greeting the server, and then asking the server for permission to start a TLS session (such as before authenticating). For IMAP, implicit TLS is typically used on port 993, and explicit TLS is used on port 143.
  8. Remy Lebeau

    DEC and FPC compatibility

    Can you be more specific? What is the actual issue? Indy uses a mix of IFDEF/ENDIF and IF/IFEND, and it works fine in both Delphi and FPC. You might consider turning on LEGACYIFEND in Delphi XE3+, if you are not already doing so.
  9. Why not? The user won't notice a difference, and your code/project will be easier to manage. You are loading the Dictionary at runtime anyway, so what does it matter where the data originates from at runtime? Make things easier on yourself.
  10. Remy Lebeau

    Code using TIdIMAP4 driving me mad !!

    It is not a bug, and it is not the SSLIOHandler that is changing the Port. It is actually the UseTLS property setter that does it. You are initializing the Port to the standard IMAP port 143, then setting UseTLS to utUseImplicitTLS, so the property setter changes the Port to the standard IMAP implicit TLS port 993. This is working as designed. If you need to use implicit TLS on port 143 (why?), then you need to set the Port after setting the UseTLS.
  11. Remy Lebeau

    communicate between 2 progs with sendmessage.

    Sorry, my bad. I left out the part where the overriden WndProc() needs to pass unhandled messages to the default handler. I have corrected my example. What I showed applies to all C++Builder versions. That won't work. That event is triggered only for messages that are posted to the main thread message queue. Which your example message is not. That likely won't work, either, because your MainForm's class name is TMainForm not TAstroclockMainForm (unless what you have shown is not your real code).
  12. Why are you hard-coding so much data directly in your source code to begin with? Why not simply store the data in an external file or database and then load it from there at runtime? If you absolutely need the data to be present statically in your app's executable, I would suggest having the auto-generator store the data in a separate file that is then linked into the app's resources at compile time, and then you can load the data from that resource at runtime. This much data really DOES NOT belong in the source code directly at all. Another benefit of this approach (using either a file, database, resource, etc) is that you can update the data on the user's machine without having to deliver a new executable from your dev machine every time (in the case of using a resource, there are plenty of 3rd party tools available to update an app's resources directly). You can, of course, also update the data on your dev machine and recompile if you really want to.
  13. That should only happen if you are sending the data in the URL query string, or in the HTTP body in 'application/x-www-webform-urlencoded' format. You need to show your actual C# and Delphi codes for the REST request, you are clearly not setting up and/or processing the request correctly. DO NOT employ the workaround you have described, that is the wrong solution. You need to fix the underlying bug in your code that is messing up the data in the first place.
  14. Remy Lebeau

    communicate between 2 progs with sendmessage.

    Is "myprog" the title for your program's TApplication window or TForm window? It makes a big difference. I'm suspecting the latter. You are installing a message handler for the TApplication window. To handle messages for the TForm window, override the TForm's virtual WndProc() method instead: void __fastcall TMainForm::WndProc(TMessage &Message) { if (Message.Msg == WM_USER) { Application->MessageBox("", "", MB_OK); Message.Result = 1; } else TForm::WndProc(Message); } That being said, WM_USER is not a good choice for inter-process communications. Use WM_APP or RegisterWindowMessage() instead.
  15. Remy Lebeau

    Thread and free

    TThread.Queue() runs asynchrously - it returns to the caller immediately and its passed procedure is executed in the main thread at some future time. So, your first example is mostly correct - the anonymous procedure will have to transfer ownership of the TStringList to the main thread so it can free the TStringList after updating the UI. However, be sure to move your try..finally into the procedure as well to ensure the TStringList is actually freed even if something goes wrong, eg: procedure TForm16.ShowComputedDetail; begin TTask.Run( procedure var lTstrings: TStrings; begin lTstrings := TStringList.create; try ComputeDetail(lTstrings); TThread.Queue(nil, procedure begin try MyTMemo.BeginUpdate; try MyTMemo.Lines.Assign(lTstrings); finally MyTMemo.EndUpdate; end; finally lTstrings.Free; end; end); except lTstrings.Free; raise; end; end); end; In your 2nd example, you will need to change TThread.Queue() to TThread.Synchronize() to ensure the TStringList is not freed before the main thread has a chance to use it, eg: procedure TForm16.ShowComputedDetail; begin TTask.Run( procedure var lTstrings: TStrings; begin lTstrings := TStringList.create; try ComputeDetail(lTstrings); TThread.Synchronize(nil, procedure begin MyTMemo.BeginUpdate; try MyTMemo.Lines.Assign(lTstrings); finally MyTMemo.EndUpdate; end; end); finally lTstrings.Free; end; end); end;
  16. Can you provide a concrete example of such a difference?
  17. Why are you using Base64 at all? REST runs over HTTP, and HTTP handles binary data without needing to encode it.
  18. You should also set the bInitialOwner parameter to False in the CreateMutex() call. You don't need ownership of the mutex just to create it and test for its existence. You can then remove the call to ReleaseMutex() as well.
  19. Remy Lebeau

    Call for Delphi 12 Support in OpenSource projects.

    Embarcadero already has private channels/forums available for its beta testers and MVPs/TPs.
  20. Just note that WideString is very inefficient in general, since it is an ActiveX/COM string type managed by the OS, not the Delphi RTL. But you also said a lot of your strings are UTF-8, and you can't store UTF-8 in a WideString. But you can use UTF8Encode()/UTF8Decode() to convert strings between UTF8String and WideString as needed. I doubt it, and if I'm not mistaken, TNT isn't even around anymore. Not to mention it is largely unnecessarily anyway, as the core Delphi classes are now Unicode capable since 2009. So many/most of the TNT classes you are using can be replaced with the native RTL/VCL counterparts (TForm, TListBox, TStringList, etc). Hard to say without seeing your actual code, and what kind of workarounds you are using. You can still use ASM coding in modern Delphi, although 64bit does have some additional restrictions on its usage.
  21. Possibly. Depends on the context in which it's being used. In any case, if you need UTF-8 strings, you should use the native UTF8String type instead of AnsiString (even in Delphi 7, you should have been doing that). If you must use UTF8 encoded AnsiString in D2009+, at least use SetCodePage() to make sure the CP_UTF8 (65001) codepage is assigned to its data. UTF8String and UnicodeString are assignment-compatible in D2009+, the RTL will automatically convert between them without any data loss (in Delphi 7, you would have had to use the UTF8Encode()/UTF8Decode() functions for that). At least with SetCodePage(), you can make sure not to lose any data if a UTF8 encoded AnsiString is assigned to a UnicodeString (the reverse is not true, though).
  22. Already covered on StackOverflow: https://stackoverflow.com/questions/77326298/trouble-inserting-text-value-into-html-input-with-twebbrowser-evaluatejavascript
  23. None of that has anything to do with migrating from 32-bit to 64-bit. Only with migrating from ANSI to Unicode. You can still use the ANSI types in 64-bit code if you need to, albeit more explicitly than before.
  24. Remy Lebeau

    C++ / windows.h and data alignment

    Didn't say there is one. From the get go, the discussion has been about compiling with <windows.h> in general, and how Microsoft doesn't force the alignment but Embarcadero does. Yes, a shame (FreePascal does). Even Marco agreed it would be a useful feature to add, but they still haven't added it yet.
  25. Remy Lebeau

    C++ / windows.h and data alignment

    That header is modified by Embarcadero, as evident by the check for __CODEGEARC__. Microsoft doesn't care about checking for CodeGear/Embarcadero compilers. The question is, what does Microsoft's native SDK version of the header look like?
×