-
Content Count
2981 -
Joined
-
Last visited
-
Days Won
134
Posts posted by Remy Lebeau
-
-
14 hours ago, Gord P said:Anyone hear anything on how likely that is?
Umm, are you not aware that there is already a 32bit Clang compiler? (two, actually). You can switch to it by turning off the "Use 'classic' Borland compiler" option in the project settings.
https://docwiki.embarcadero.com/RADStudio/en/Win32_Clang-enhanced_Compilers
The difference between the 32bit Clang compiler and the newly released 64bit Clang compiler (besides bit-size, obviously) is that the 64bit compiler uses a newer version of clang. But, after it has matured a little bit, I'm sure they will update the 32bit compiler too, as 32bit development is still popular. But, at least you can get started using clang today.
-
29 minutes ago, aehimself said:That's exactly what I meant. If no exceptions are thrown, the string was successfully converted and the return value will initialize the variable correctly.
Sorry, I had misread your earlier message.
-
12 hours ago, aehimself said:Without checking the source, StrToFloat has two options: either throw an exception or to return a value.
StrToFloat() does not have an option to return a default value. You need to use TryStrToFloat() for that.
-
1
-
-
19 hours ago, rossh said:I realize the compiler no longer accepts embedded asm, and rejects trying to inline it.
In 64bit, you can't mix inline assembly with Pascal code in the same function, but you can still write entire functions in just assembly and then call them from Pasal functions.
QuoteBut I need to insert about 60 bytes as a place marker at the front and end of a particular function. In asm its done with db 1,2,3,4,5,6,7,8. How can I do that now in pascal? i.e. insert some superfluous bytes into the function code at beginning and end?
You can't. At least, not in a Pascal function, where you don't have access to modify the function's prolog and epilog.
-
7 hours ago, chkaufmann said:You mean get that exception?
You said: "But in the first one I end method TIdIOHandler.RaiseConnClosedGracefully". That implied to me that you are directly calling RaiseConnClosedGracefully() yourself. If that is not the case, then ignore what I said. Indy will raise an EIdConnClosedGracefully exception when the extra client disconnects if it does not send a request.
-
33 minutes ago, emileverh said:Any idea if there is an API to add a kind of duplication number like: file (1).txt, file (2).txt, file (3).txt ?
Use the Win32 SHFileOperation() API to copy the file with the FOF_RENAMEONCOLLISION flag:
QuoteGive the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists at the destination.
If you need to know what the copied filename was renamed to, include the FOF_WANTMAPPINGHANDLE flag as well:
QuoteIf FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object that contains their old and new names to the hNameMappings member. This object must be freed using SHFreeNameMappings when it is no longer needed.
Alternatively, on Windows Vista+, you can use the IFileOperation API instead, using IFileOperation.SetOperationFlags() to set the FOF_RENAMEONCOLLISION flag, IFileOperation.CopyItem() and IFileOperation.PerformOperations() to perform the copy, and if needed use an IFileOperationProgressSink event sink to discover the copied filename in the PostCopyItem event.
-
1
-
-
2 hours ago, chkaufmann said:It seems, there are two connections when I send a GET request with postman.
That is a known issue with postman.
2 hours ago, chkaufmann said:But in the first one I end method TIdIOHandler.RaiseConnClosedGracefully.
And how are you doing that, when there is no OnCommandGet event fired for that connection? The only option would be to use the OnConnect event, in which case you could instead just assign a ReadTimeout to the connection and let TIdHTTPServer close the connection when no request arrives.
-
You cannot delete a file that is in use, unless the app that is using the file explicitly permits the deletion (by specifying FILE_SHARE_DELETE when opening the file). Nobody does that under normal usage, so you will need to detect when this condition happens (check GetLastError() when the deletion fails) and then. either 1) retry the deletion later or 2) ask Windows to delete the file on the next reboot (via MoveFileEx(MOVEFILE_DELAY_UNTIL_REBOOT)).
-
21 hours ago, chkaufmann said:Now I sent a simple GET request with Postman to my server and noticed, that two context objects were created, but the OnCommandGet event is only called once. What is the reason for that?
A new Context is not created until a client is accepted. Only 1 Context is created per client. So, there must have been multiple clients accepted. But maybe a client didn't send a request.
QuoteThen I plan to iterate all current requests like this
You should put that loop inside a try..finally block to ensure the list is always unlocked.
QuoteCan I be sure, that all items will be alive. Or is it possible, that one of the context items was freed before I could read info from it?
The list will never hold a freed object, ie the pointers in it are always valid while inside of the lock. Make sure you are not accessing the pointers outside of the lock.
There is no guarantee that a client assigned to a Context is still connected to the server while you are accessing the list. But the objects in a Context will still be alive while the list is locked.
-
tag as String
in VCL
5 hours ago, Anders Melander said:The point was that since it was originally (refs "to begin with") declared as an integer, not a nativeint, the original intent obviously wasn't that it could be used for pointers. It just so happened that it could.
I'll rephrase.
Prior to the introduction of 64bit, the Tag was an Integer and pointers fit in an Integer, so it was common to store pointers in a Tag. When 64bit was added, the Tag became a NativeInt to preserve existing code in common use.
-
1
-
-
5 hours ago, Cristian Peța said:I am not sure right now but I suppose ServiceCreate and ServiceExecute are not in the same thread.
That is correct. The TService's DataModule is created in the process' main thread, whereas its On(Start|Execute|Stop|Shutdown) events are called in a worker thread.
-
2 hours ago, Ian Branch said:I asked ChatGPT to write a unit...
Never a good idea...
2 hours ago, Ian Branch said:function IsFileOpen(const FileName: string): Boolean; var HFile: THandle; begin HFile := CreateFile(PChar(FileName), GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); Result := (HFile = INVALID_HANDLE_VALUE); if not Result then CloseHandle(HFile); end;
This function is not very accurate. A file can fail to open for any number of reasons, and you are treating all errors as success. A more accurate approach would be to open the file in exclusive mode and then check if the error code is ERROR_SHARING_VIOLATION specifically.
14 minutes ago, Ian Branch said:That solved that issue but unfortunately I don't understand enough about using Windows stuff to understand why
GetTokenInformation(TokenHandle, TokenUser, nil, 0, ReturnLength);
and
if GetTokenInformation(TokenHandle, TokenUser, ReturnLength, ReturnLength) then
are not hapy in this context. 😞
Can you be more specific? What is the actual problem you are having with it?
-
28 minutes ago, Luca Pretti said:An AV near address 0 usually means a nil pointer is being dereferenced. Did you try debugging your service?
QuoteThis is the code in the ServiceExecute event handler:
Where and how are you creating the Python Engine?
-
tag as String
in VCL
19 minutes ago, Lars Fosdal said:I've gone even deeper down the rabbit whole and referenced object instances through the tag... I am not proud of it.
That is actually quite common, and is why the Tag is a NativeInt to begin with.
-
4 minutes ago, boris.nihil said:where can i find needed delphi units for this new openssl ?
(libeay32.pas,libexslt.pas,libxml2.pas,libxmlsec.pas...)
I can't answer that, since I don't know where you got those source files from to begin with. Those are 3rd party units, so you will have to figure out who authored them and ask them for updates, or find alternative replacements. This has nothing to do with Indy.
-
36 minutes ago, boris.nihil said:"Delphi import unit for OpenSSL libeay, version 0.7m, 2010-11-05"
There has never been a 0.7 version of OpenSSL. In 2010, OpenSSL was at 1.0.0. 0.9.8 was released in 2005.
36 minutes ago, boris.nihil said:it works only with dlls from 2005 year (ssleay32.dll and libeay32.dll)
why this EXE dont work with some newer dlls, from 2019 for example...
OpenSSL 1.1.0 was released in 2016, and had significant changes to OpenSSL's APIs that are not backwards compatible with the older version your code apparently depends on. Your code needs to be updated to work with the newer APIs.
-
tag as String
in VCL
12 hours ago, Jim McKeeth said:Convert the string into an array of AnsiChar, which is just an array of bytes, which is absolute to a NativeInt....
So there is no pointer....
True. Now I see what the code is doing. It's stuffing the first 4 (32bit) or 8 (64bit) characters of the string directly into the NativeInt's bytes. So, if the string is longer than the NativeInt can hold, the remaining characters get lost. Storing the string's pointer into the NativeInt would preserve the entire string, but at the cost of having to manage its reference count properly.
-
tag as String
in VCL
42 minutes ago, Jim McKeeth said:This might be an even worse idea.
Very bad idea. ReadTagString() is not so bad, but IDK what WriteTagString() is trying to accomplish. It is converting characters into bytes, completely ignoring the pointer that is inside the string. It is not the inverse of ReadTagString().
-
tag as String
in VCL
9 hours ago, Brandon Staggs said:What could possibly go wrong
😎
-
2
-
-
13 minutes ago, DelphiUdIT said:Ehmmm, I explain bad, it's your update. The Palette come from Indy source repo, already in the recenct past he was added (form Oauth-ssl branch ?).
Yes, the ssl-oauth branch was registering the components on the palette, but I did not have actual icons for them until right before I merged the branch. I didn't have a chance to test the icons in the IDE.
-
tag as String
in VCL
7 hours ago, Zakaria said:how add property tagString to all delphi Compememet
You can't add a new property to all components. But, the existing Tag property is a NativeInt, so it can hold a String (which is just a pointer under the hood), eg:
var tagStr: NativeInt := 0; String(Pointer(tagStr)) := SomeString; SomeComponent.Tag := tagStr; ... var tagStr := SomeComponent.Tag; SomeString := String(Pointer(tagStr));
Just make sure you release the String properly before the Component is destroyed, eg:
var tagStr := SomeComponent.Tag; String(Pointer(tagStr)) := '';
-
2
-
-
21 hours ago, DelphiUdIT said:I install the new Indy from github and the old PR299 (with the same changes like always to maintain compatibility with Embarcadero environment and third parties) and all is working with RAD 12.2 Patch 1.
That's good to hear, thanks.
Though, PR299 is closed now. There is new effort for OpenSSL 3x support in a new repo:
https://github.com/IndySockets/IndyTLS-OpenSSL
https://www.indyproject.org/2024/08/05/ongoing-work-in-indy-for-openssl-updates/
21 hours ago, DelphiUdIT said:Also the new OAuths in the components palette. I didn't try them.
Oh good, glad to see they made it onto the palette ok. The icons were a last-minute addition.
21 hours ago, DelphiUdIT said:The new (but it worse) is that "LivePreview" should not be installed.
https://github.com/IndySockets/Indy/wiki/Updating-Indy#delphicbuilderradstudio-101-berlin-and-later
-
2 hours ago, Mark- said:I know that works for non modal forms, never tried with modal forms.
Just tried with 10.2 and OnDeactivate is not called with a modal form, unless I am doing something wrong.
Sorry, I meant the TApplication(Events).OnDeactivate event, not the form's OnDeactivate event.
You can't click on another form in your app since it has been disabled by the modal form. But, if you click outside of the app then the modal form will lose focus, triggering the TApplication(Events).OnDeactivate event. You can then close the modal form.
-
26 minutes ago, softtouch said:How can I close this form when the user click outside the form?
You can call the form's Close() method, or set the form's ModalResult property, in the form's OnDeactivate event.
What is the likelihood that the new Clang tool chain will be accessible for 32 bit projects?
in General Help
Posted
I don't see why. It's still clang, just a newer version with a higher language compliance.
At this time, the newer clang compiler is available only for 64bit.