Leaderboard
Popular Content
Showing content with the highest reputation on 04/23/25 in all areas
-
I might do that, explaining the best I can what happened here. And about the demo, yes it is really good but overkill for my use case, but now I know the imports I need are in the Kastri repo, on the DW.iOSapi.Photos unit, so I can use just the bits related to permission checking and requesting. But... - PHPhotoLibrary.requestAuthorization asks for full-access, so aware users will see the inconsistency between the request and the purpose (save a single image) and will deny. I can always ask them again to give the previously denied permission explaining what's happening, but still feels hacky. Someone at Apple forgot a couple things about consistency when designed this. - On iOS 14+ we finally have ways to request and check write-only access to the photo library via authorizationStatusForAccessLevel and requestAuthorizationForAccessLevel. These are missing from Kastri but are trivial to import, except for requestAuthorizationForAccessLevel which asks for a "void (^)(PHAuthorizationStatus status)" parameter as the handler. That thing looks scary.
-
In addition to allowing to change keyboard shortcuts, GExperts has the Uses Clause Manager which on the Identifier tab offers similar functionality as the Delphi Uses Helper. The UI is very different though, but it also finds partial matches (but not typos).
-
In this post, I'll share all the workarounds I use when LSP fails, which have greatly helped me during coding. Hopefully, you'll find them useful before Embarcadero completely fixes the LSP Server, which I'm sure will be soon. I'll also mention GExperts throughout this post, as it includes some useful features that can speed up using the tools listed below. Delphi Uses Helper Link: https://delphisorcery.blogspot.com/2021/03/introducing-delphi-uses-helper.html Feature: proper replacement for the Find Unit... refactor (Ctrl+Shift+A) feature. Description This has been by far the most helpful plugin. It's as simple as typing the name of a type and pressing Ctrl+Shift+A to find the unit where it's declared. When the window pops up, you can press Enter to add the unit to the uses section (use the left/right arrows to switch between interface and implementation sections), or press Shift+Enter to open the unit and jump to the line where the type is declared. GExperts bonus: The IDE already has a similar feature under the Refactor menu with the same shortcut, Ctrl+Shift+A, but it doesn’t work well and is certainly not as fast as Delphi Uses Helper. However, sometimes the default feature will trigger instead of the plugin (e.g., when pressing the shortcut without any text at the caret position). To remove the default shortcut, use GExperts' IDE Menu Shortcuts: find the shortcut under Refactor > Find Unit... (it should be the last one), and assign it to another key. MMX - Show Related Classes Link: https://www.mmx-delphi.de/ Feature: shows ancestor class, implemented interfaces, and sibling classes for a given class. Description Want to quickly navigate to a class’s ancestor or interface, or find out which siblings it has? This feature gives you exactly that, neatly and efficiently. To use it, right-click and go to MMX Commands > Navigate and Move > Show Related Classes. Or even better, map a shortcut by going to MMX > Properties > Key Bindings and finding Show Related Classes. I’ve personally mapped it to Shift+Alt+3. MMX - Open Unit... Link: https://www.mmx-delphi.de/ Feature: displays searchable units based on set configuration. Description Quickly displays all units based on your configuration. The configuration allows for adding units from the currently opened project or project group, and the following paths: Project Search path, IDE Library path, and IDE Browsing path. Find Original Symbol Feature: additional help navigating to a unit, type, or method. Description Using Find Declaration (Ctrl+Click) is known to fail occasionally, especially on bigger projects. What I've found helpful at times is to try using the Find Original Symbol that's located under the Search > Find Symbols menu item. I've personally mapped the Find Declaration to Ctrl+< and the Find Original Symbol to Ctrl+Shift+< through the GExperts IDE Menu Shortcuts, and I spam them when needed. It does help sometimes. Add a shortcut to the Reload LSP Server menu item Link: https://github.com/havrlisan/zx-idetools/blob/main/Source/Zx.IT.KeyBinding.ReloadLSPServer.pas Description In Delphi 12.1, a menu item Reload LSP Server was added under the Tools menu. Before that, you could add a custom tool to manually kill the LSP, and the IDE would restart it automatically. Unfortunately, they didn't add a shortcut for the menu item, so your options are limited to mouse clicks or to clicking Alt > T > accelerated key. Note that the accelerated key will be automatically assigned, and it depends on your menu items under the Tools menu, which sucks because that's the most changeable menu (because of custom tools, or third-party plugins). Usually, I'd use GExperts IDE Menu Shortcuts to manually add the shortcut, but the Reload LSP Server menu item doesn't show up there. After some debugging, I realized that the menu item in question isn't registered on IDE startup, but is loaded sometime after all other packages are loaded. My best guess is that the GExperts remembers the menu items when loaded, and doesn't re-fetch them afterward (I'm too lazy to search through the source code, sorry). So I decided to implement an IDE notifier that listens to a "ProjectGroupOpen" notification and then tries to find the Reload LSP Server menu item and assigns the shortcut to it. I've set the default shortcut to Alt+Shift+W, but the code is quite simple and is easily portable to a package of your own. That's all I've got so far. If you have some other features or tips, feel free to share them in this post!
-
In Windows Defender you can exclude by process in addition to by file/folder/file type. Process: Adding an exclusion for a process means that any file opened by that process will be excluded from real-time scanning. These files will still be scanned by any on-demand or scheduled scans, unless a file or folder exclusion has also been created that exempts them Tip: It's recommended that you use the full path and file name to exclude a specific process. This makes it less likely that malware could use the same filename as a trusted and excluded process and evade detection. Ref: Virus and Threat Protection in the Windows Security App - Microsoft Support Final note about testing IDE start speed: Windows Defender does cache real-time scanning results so IDE launches after the first will be faster even with no exclusions.
-
One of the first things I did with the vm is uninstall Onedrive and alike. Usually I don't browse inside the vm, but I'll need to download and install some programs, and some of our applications include internet connections to third parties. I've always used vms for Delphi without these problems, but this is the first time I use version 12.3 and also the first time I use Windows 11 (I can´t delay using this crap any longer) and VirtualBox 7, so I'd like to know which of them triggered this issue. I suppose I'm not the only one with this configuration. If I exclude e:\Embarcadero and C:\Users\usuario\Documents\Embarcadero\Studio\23.0\CatalogRepository (I don't understand why the installer used that folder ignoring the one I chose during installation) would that be enough or I'll have to exclude also any components I use like e:\Raize,.... ?
-
Run as admin on unauthorized Windows username
Mustafa E. Korkmaz replied to Mustafa E. Korkmaz's topic in Windows API
I found a not bad solution. If the exe does not have admin permissions, CreateProcessAsUser does not work at all. If CreateProcessWithLogonW is used directly, the exe does not need to have admin privileges. When using CreateProcessWithLogonW, the exe to be run must be in a common directory. Otherwise, it gives an access denied error. In other words, it must be in a directory that both the unauthorized user and the admin user can access. It can be the C:\Users\Public\ directory. When the button is pressed while the Delphi application is on the desktop of the unauthorized user, it can copy the exe file to the C:\Users\Public\ directory and run it directly as admin with CreateProcessWithLogonW. function RunAsAdminWithPassword( UserName, Password, Domain, AppPath: WideString) :integer; var SI: TStartupInfoW; PI: TProcessInformation; begin result := 0; ZeroMemory(@SI, SizeOf(SI)); SI.cb := SizeOf(SI); if CreateProcessWithLogon( PWideChar(UserName), PWideChar(Domain), PWideChar(Password), LOGON_WITH_PROFILE, nil, PWideChar(AppPath), CREATE_NEW_CONSOLE, nil, nil, SI, PI) then begin CloseHandle(PI.hProcess); CloseHandle(PI.hThread); end else result := GetLastError; end; procedure TForm1.Button1Click(Sender: TObject); begin copyExetoPublic(); RunAsAdminWithPassword( 'User', 'test123', '.', 'C:\Users\Public\' + ExtractFileName( application.ExeName ) ); end; -
This depends a bit on what you really need to test in your app. If you want to test all kinds of dynamic hardware stuff a phone can do, then I would always recommend a real device. Only that can behave truly by accleration/motion/orientation sensors, touchscreen, phone calls, etc., the simulator can only roughly simulate that. If your app is mainly a "form" app with controls, not using a lot of specific hardware of the phone, then the simulator could be good enough for you. As far as I know, the debugging doesn't work under iOS simulator too, but still under Macos. So it is always a good idea to test under Windows/Macos first, and only then check the "view impression" and handling by iOS simulator or device.
-
They are not buffer overflows; The protocol for a lot of API functions is to first make a call with a small or no buffer and then repeat the call, if needed, with the required buffer size returned by the first call. So all those BUFFER OVERFLOW are just the first call saying that some of the data returned was truncated to fit the supplied buffer. See: https://learn.microsoft.com/en-us/archive/blogs/markrussinovich/buffer-overflows-in-regmon-traces Apart from that, the very first thing I look for when people have performance problems is cloud storage such as OneDrive, DropBox, Google Drive, etc. The cloud synchronization can simply kill a system. Disable it and only sync when you have to.
-
Well, I created an app from scratch afterwards and all went well. I remember I tried to change API Level but that didn't work out, so I did the approach above. Thanks
-
Can you restart the LSP or do you have to restart the whole IDE?
Anders Melander replied to Der schöne Günther's topic in Delphi IDE and APIs
I can confirm that Uwe's solution works. I've been using it for a long time without any problems. The IDE automatically restarts the LSP if/when it dies (apparently they expected it to crash occasionally).