Jump to content

Shrinavat

Members
  • Content Count

    70
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Shrinavat

  1. Hello everyone, I'm working on a utility that gathers PC configuration information and displays it in a TTree component. I want to be able to save this information to a file so that it can be compared with a similar file created at a later time. This would allow me to detect any changes in the PC's configuration, such as adding or removing hardware components. My main challenge is deciding on the best format to store this data for easy comparison and change detection. I've considered options like JSON, XML, and plain text, but I'm unsure which would be most suitable. A simple line-by-line comparison of a text file might not be reliable, as the order of components could change without signifying an actual configuration change (e.g., reordering hard drives). Could anyone offer advice on the best approach for storing and comparing this type of data? Are there any specific technologies or libraries that would be helpful for this task? Any guidance would be greatly appreciated!
  2. Thank you for the suggestion! Using a sorted CSV file with a dedicated comparison tool sounds like a very interesting and potentially robust approach. I'll definitely explore this option further. Thanks for sharing the XML example. I'm already familiar with saving the configuration in XML format 🙂. However, my main challenge lies in efficiently comparing two XML files to identify meaningful changes. I'm open to suggestions on how to best approach this comparison aspect. That's an interesting idea using SQLite. My main concern with a database approach is the unknown and variable number of fields. I'm not sure how to design the database structure to accommodate this and still allow for easy comparison between different snapshots. Could you elaborate on how you envision structuring the database to handle this dynamic nature and facilitate efficient comparisons?
  3. How can I implement functions for basic string obfuscation and deobfuscation in Delphi, where the input string can contain Latin and Cyrillic letters, digits, and special characters !@#$%^&*()_+-=[]{}\|;':",./<>? Requirements: The obfuscated string must contain only Latin letters and digits. The obfuscated string must have the same length as the original string. Strong cryptographic security is not required. I'm looking for a simple solution that can handle a variety of characters and maintain the original string length. Any suggestions or code examples would be greatly appreciated.
  4. Thanks for the feedback! I ended up implementing a modified ROT13 algorithm with a custom alphabet, as shown in the code below. Initial tests indicate that it meets my requirements effectively. const ALL_CHARACTERS_CONSTANT = '!#$%&()*+,-./:;<=>?@[\]^_`{|}~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя'; function ROT13Encrypt(const Input: string): string; var idx, newIdx: Integer; halfLength: Integer; begin Result := ''; halfLength := Length(ALL_CHARACTERS_CONSTANT) div 2; for var i := 1 to Length(Input) do begin idx := Pos(Input[i], ALL_CHARACTERS_CONSTANT); if idx > 0 then begin newIdx := ((idx - 1 + halfLength) mod Length(ALL_CHARACTERS_CONSTANT)) + 1; Result := Result + ALL_CHARACTERS_CONSTANT[newIdx]; end else Result := Result + Input[i]; end; end; function ROT13Decrypt(const Input: string): string; begin // ROT13 decryption is the same as encryption in this case Result := ROT13Encrypt(Input); end;
  5. Thank you for your insights. I understand the challenges involved in meeting both requirements simultaneously. I'm willing to remove the constraint that "The obfuscated string must contain only Latin letters and digits." Revised requirements: The obfuscated string can contain any printable characters. The obfuscated string must have the same length as the original string. Strong cryptographic security is not required. The input strings will generally not exceed 30 characters in length. With this revised requirement, are there any suitable algorithms or approaches you could suggest for implementing the obfuscation and deobfuscation functions?
  6. I'm using the Async abstraction from the OmniThreadLibrary to ping multiple hosts in background threads (one thread per host). In the main thread, I want to perform some actions with the ping results based on the host ID. Here's a simplified version of my code: procedure Test; var arr_id: TArray<LongWord>; arr_ip: TArray<string>; begin arr_id := [1,2,3,4,5,6,7]; arr_ip := ['192.168.16.1','192.168.16.2','192.168.16.3','192.168.16.4','192.168.16.5','192.168.16.6','192.168.16.7']; for var i := Low(arr_id) to High(arr_id) do begin Parallel.Async( procedure (const task: IOmniTask) var PingResult: Boolean; rec_id: LongWord; rec_ip: string; begin // background thread rec_id := arr_id[i]; rec_ip := arr_ip[i]; // PingResult := PingHost(rec_ip); // in the main thread task.Invoke( procedure begin // some actions with ping results based on host ID mmoLog.Lines.Add(Format('rec_id=%d, rec_ip=%s', [rec_id, rec_ip])); end); end); end; end; I'm getting inconsistent results. For example: rec_id=3, rec_ip=192.168.16.3 rec_id=3, rec_ip=192.168.16.3 rec_id=135299280, rec_ip=烬Ŧ rec_id=135299280, rec_ip=烬Ŧ rec_id=135299280, rec_ip=烬Ŧ rec_id=135299280, rec_ip=烬Ŧ rec_id=135299280, rec_ip=烬Ŧ or rec_id=2, rec_ip=192.168.16.2 rec_id=3, rec_ip=192.168.16.3 rec_id=4, rec_ip=192.168.16.4 rec_id=7, rec_ip=192.168.16.7 rec_id=7, rec_ip=192.168.16.7 rec_id=7, rec_ip=192.168.16.7 rec_id=135299280, rec_ip=烬Ŧ Not all IPs are being pinged, and some are pinged multiple times. Also, I get garbage data in some cases. How can I achieve the desired behavior, where each IP is pinged once and the results are processed correctly in the main thread? Alternatively, how can I rewrite the code using TTask?
  7. The issue stemmed from how variables were captured within the closure passed to Parallel.Async. The loop variable i was not correctly captured, leading to incorrect values being used in the background tasks. The following code demonstrates my working solution: procedure Test; var arr_id: TArray<LongWord>; arr_ip: TArray<string>; procedure CreatePingTask(const id: LongWord; const ip: string); begin Parallel.Async( procedure (const task: IOmniTask) var PingResult: Boolean; begin // background thread // Simulate ping PingResult := Random(2) = 1; // random result for demonstration Sleep(Random(5000)); // simulate ping delay // in the main thread task.Invoke( procedure begin mmoLog.Lines.Add(Format('PingResult=%s, rec_id=%d, rec_ip=%s', [PingResult.ToString, id, ip])); end); end); end; begin arr_id := [1,2,3,4,5,6,7]; arr_ip := ['192.168.16.1','192.168.16.2','192.168.16.3','192.168.16.4','192.168.16.5','192.168.16.6','192.168.16.7']; for var i := Low(arr_id) to High(arr_id) do CreatePingTask(arr_id[i], arr_ip[i]); end; Explanation: To ensure each background task receives the correct ID and IP, we pass them as parameters to the CreatePingTask procedure. This creates a separate copy of the variables for each task. task.Invoke is used to synchronize with the main thread and update the UI with the ping results. This approach ensures that each host is pinged exactly once and the results are processed correctly in the main thread. I'd love to get some expert opinions on my solution. Are there any "gotchas" I should be watching out for?
  8. Shrinavat

    Delphi 12 and *.dsv

    I recently installed RAD Studio 12 Pro with Delphi. Now a ProjectName.dsv file is being created in the project folder. What is this, and how can I disable the creation of this file? Here's what its contents look like for example: [ClosedView_RDpcRGVscGhpX3Byb2plY3RzXENhbGxDZW50ZXJcQ2FsbENlbnRlci5kcHI=] Module=D:\Delphi_projects\CallCenter\CallCenter.dpr CursorX=1 CursorY=18 TopLine=1 LeftCol=1 Elisions= Bookmarks= EditViewName=D:\Delphi_projects\CallCenter\CallCenter.dpr [ClosedView_RDpcRGVscGhpX3Byb2plY3RzXENhbGxDZW50ZXJcX3VuaXRzXGZyYW1lc1xmclJlcG9ydF9UcmFu c2ZlcnJlZFRvQW5vdGhlckRlcGFydG1lbnQucGFz] Module=D:\Delphi_projects\CallCenter\_units\frames\frReport_TransferredToAnotherDepartment.pas CursorX=1 CursorY=1 TopLine=1 LeftCol=1 Elisions= Bookmarks= EditViewName= [ClosedView_RDpcRGVscGhpX3Byb2plY3RzXENhbGxDZW50ZXJcX3VuaXRzXGZvcm1zXGZybVJlZmVyZW5jZS5w YXM=] ...
  9. What is the purpose of this feature? How can I change the color of the tab in the code editor? I am unable to find an option to modify the color in the tab settings.
  10. Shrinavat

    Allow tabs to use custom colors

    Oh, now it's clear. We can't manually set the color of the tabs. How quaint.
  11. Shrinavat

    Allow tabs to use custom colors

    Maybe the 'Allow tabs to use custom colors' option is like the Force in Star Wars - a mystical power that only a few chosen ones can truly understand and control. May the colors be with you, young Padawan. ✨ ...on a more serious note, has anyone cracked the code on how to actually use this mysterious option? Does anyone actually know how to change the tab colors?
  12. Shrinavat

    The GetIt server is back online - With the 12.0 Patch 1

    (deletia)R120.patch1-20240131.zip
  13. Upon each launch of IDE, the Component Palette panel consistently shifts to the right by a specific distance. This behavior requires me to manually drag the panel back to its original position on the left side every time I start Delphi 12. Additionally, I have observed that the "Lock Controls" icon from the "View" toolbar disappears. I have manually added this icon to the toolbar, but it vanishes. It reappears only after selecting the same action through the "Edit|Lock Controls" menu. I have attached a screenshot illustrating the issue. I would like to inquire if there is a solution or workaround to address this problem. Is there a way to lock or fix the position of the Component Palette panel, so it remains in place across Delphi 12 sessions? Additionally, I am curious about where the configuration data for the panel's position is stored. Does Delphi 12 save this information in the registry, a configuration file, or elsewhere?
  14. Shrinavat

    Delphi 12 Component Palette Panel Shift Issue

    Yes, I have different Desktops. *.DST files do not have component palette properties. Deleting both your own Desktops and the default ones did not affect the offset position of the component palette :-(
  15. Shrinavat

    Delphi 12 Component Palette Panel Shift Issue

    Uninstalling CnPack had no effect, the panel appeared to be offset as well.
  16. Shrinavat

    Advise the component for editing tables

    Steema TeeGrid The grid component for Delphi VCL & FMX offers a very fast grid for your RAD Studio projects
  17. I'm encountering a problem with the color names in freshly installed Delphi 12, and this issue also existed in Delphi 11.x. The problem is observed as a text "overlay" in any Object Inspector field related to color, as illustrated in the attached animation. It seems to occur regardless of whether any experts or updates are installed. How can I address this issue?
  18. I've found the source of the problem. It turned out to be third-party components - ESBPCS for VCL. If they are disabled, then the problem disappears. As @balabuev rightly pointed out, here's what's to blame: "Non-standard property editors are installed. More technically, this happens when a property editor implements the ICustomPropertyDrawing interface but does not implement the more recently introduced ICustomPropertyDrawing80 interface." The developer of these components has already been notified.
  19. Shrinavat

    Object Inspector issue in 10.4.2??

    @maloboDid you find a solution? I have the same issue
  20. Hmmm... a similar problem is described here But there is no solution how to fix it.
  21. Shrinavat

    .exe File not outputting

    @Remy Lebeau Could you please explain what is the point of using UniqueString (sCommand)?
  22. Shrinavat

    Delphi 11.3 is available now!

    Yes, I also turned off this feature because of the spontaneous jumps of the text. It's very annoying. Is there any RSP about this?
  23. Hello, I know there are advanced Clever Internet Suite users here who might be able to help me with advice. To send an image to a Telegram channel, I use the following code: const urlTGSendPhoto = 'https://api.telegram.org/bot%s/sendPhoto'; BOT_API_KEY = 'xxxxxxxxxxxxxx'; CHANNEL_NAME = 'xxxxxxxxxxxxxx'; ... clHttpRequest.AddFormField('chat_id', CHANNEL_NAME); clHttpRequest.AddSubmitFile('photo', 'chart.png'); var s := clHttpTG.Post(Format(urlTGSendPhoto, [BOT_API_KEY]), clHttpRequest); where 'chart.png' is the name of the image file on disk. It works great. Can someone please tell me how to use a stream (TMemoryStream/TFileStream) or TPngImage/TJPEGImage/TBitmap instead of a file (that is, without the need to save the file to disk)?
  24. Thanks to the author of the library we were able to find a solution: https://github.com/CleverComponents/Clever-Internet-Suite-Tutorials/tree/master/vcl/SendTelegramPhoto
  25. Shrinavat

    Format uses clause

    Exactly right! I'm sorry, my bad.
×