PeterPanettone
Members-
Content Count
1318 -
Joined
-
Last visited
-
Days Won
5
Everything posted by PeterPanettone
-
Filter Checkboxes for the Messages list?
PeterPanettone replied to PeterPanettone's topic in GExperts
There should also be a filter box to filter the messages for a search term (showing only the messages containing the search term), for example: This would be very useful! -
Unfortunately, I have a specific library for which I have only Delphi 10.1 Berlin DCUs (no source code), but I need to use this library in Delphi 10.3.3 Rio. Which is the best strategy to achieve this? (DLLs, Packages, ...)
-
Filter Checkboxes for the Messages list?
PeterPanettone replied to PeterPanettone's topic in GExperts
A colleague has posted a quality report: https://quality.embarcadero.com/browse/RSP-27547 Please vote for it. -
Filter Checkboxes for the Messages list?
PeterPanettone replied to PeterPanettone's topic in GExperts
I have created a request issue here: https://sourceforge.net/p/gexperts/feature-requests/103/ -
How to use library from Delphi 10.1 DCUs in Delphi 10.3.3?
PeterPanettone replied to PeterPanettone's topic in VCL
I have changed the code using PWideChar now: DLL: function JclShell_DisplayPropDialog(AHandle: THandle; AFile: PWideChar): Boolean; stdcall; begin Result := JclShell.DisplayPropDialog(AHandle, string(AFile)); end; Host exe: function JclShell_DisplayPropDialog(AHandle: THandle; AFile: PWideChar): Boolean; stdcall; external myDLL; procedure TForm3.btnTestClick(Sender: TObject); begin if JclShell_DisplayPropDialog(0, PWideChar(edtFile.Text)) then Self.Caption := 'Success' else Self.Caption := 'Failure'; end; It does work well, no crash. -
How to use library from Delphi 10.1 DCUs in Delphi 10.3.3?
PeterPanettone replied to PeterPanettone's topic in VCL
After having removed ShareMem from the uses list in both the DLL and the host exe, it does not crash anymore! -
How to use library from Delphi 10.1 DCUs in Delphi 10.3.3?
PeterPanettone replied to PeterPanettone's topic in VCL
Done. It works, but when I close the host exe it CRASHES. The exe also crashes on Close even if I don't press the button! See attachment: TestDLL.zip -
How to use library from Delphi 10.1 DCUs in Delphi 10.3.3?
PeterPanettone replied to PeterPanettone's topic in VCL
Can you indicate me a practical example? (There is no theory about the difference between theory and practice) -
How to use library from Delphi 10.1 DCUs in Delphi 10.3.3?
PeterPanettone replied to PeterPanettone's topic in VCL
That is OBVIOUS. -
When trying to build r3040 in Delphi 10.3.3 I got this warnings/errors: [Exec Error] Warning(1): File not found: [...]\gexperts-code-r3040-trunk\Projects\DelphiXx103\GExpertsRS103.manifest.in(EFileNotFound) [Exec Error] Der Befehl "call ..\..\buildtools\prebuild.cmd "C:\COMP\_Addons\GExperts\GExperts Sourcecode\gexperts-code-r3040-trunk\Projects\DelphiXx103\GExpertsRS103.dproj"&&call ..\..\buildtools\movedll.cmd "C:\COMP\_Addons\GExperts\GExperts Sourcecode\gexperts-code-r3040-trunk\Binaries\GExpertsRS103.dll"" wurde mit dem Code 9009 beendet.
-
Thanks, now the errors have disappeared.
-
Floating form designer not automatically restored when reopening a project
PeterPanettone posted a topic in Delphi IDE and APIs
In the Delphi Rio 10.3.3 IDE, I have activated the floating form designer by unchecking the "Embedded designer" checkbox in the Options dialog: The floating form designer normally stays on the second monitor. When I reopen a VCL Application project, the previously opened form designer is not automatically restored and I have to manually open it with F12 which often takes a relatively long time. This is one of the small IDE annoyances. Has anyone also experienced this? -
Strange behavior when restoring Delphi v10.3.3 IDE window from MINIMIZED window state
PeterPanettone replied to PeterPanettone's topic in Delphi IDE and APIs
Seems the toolbars are a mess. -
Strange behavior when restoring Delphi v10.3.3 IDE window from MINIMIZED window state
PeterPanettone replied to PeterPanettone's topic in Delphi IDE and APIs
Do you also have an unusual WAITING TIME of about 2 - 3 seconds when restoring the IDE window from minimized state? -
Strange behavior when restoring Delphi v10.3.3 IDE window from MINIMIZED window state
PeterPanettone replied to PeterPanettone's topic in Delphi IDE and APIs
What is your screen resolution? -
Why do you want to throw away the fish before eating it?
-
This is a more SECURE version of SaveShortcutShellLinkAsAdministrator for the demo app: procedure TformMain.SaveShortcutShellLink(const AFile: string); var SL: JclShell.TShellLink; HR: Integer; begin SL.Target := 'C:\Windows\System32\notepad.exe'; SL.HotKey := Winapi.Windows.MakeWord(Byte(HotKey1.HotKey), Byte(HotKey1.Modifiers)); // other ShellLink properties: SL.Description := 'My description'; HR := JclShell.ShellLinkCreate(SL, AFile); if HR <> Winapi.Windows.S_OK then begin if not SaveShortcutShellLinkAsAdministrator(AFile, SL) then MessageDlg('The Shortcut ShellLink could not be saved even with Administrator rights.', mtError, [mbOK], 0); end; end; function TformMain.SaveShortcutShellLinkAsAdministrator(const AFile: string; AShellLink: JclShell.TShellLink): Boolean; // SECURELY create Shortcut ShellLink as administrator var ts, ThisTempLnkFile, ThisParams, SourceHash, TargetHash: string; function GetHashFromFile(const AFileToHash: string): string; var IdMD5: IdHashMessageDigest.TIdHashMessageDigest5; FS: TFileStream; begin IdMD5 := IdHashMessageDigest.TIdHashMessageDigest5.Create; FS := TFileStream.Create(AFileToHash, fmOpenRead or fmShareDenyWrite); try Result := IdMD5.HashStreamAsHex(FS); finally FS.Free; IdMD5.Free; end; end; begin Result := False; // create temporary ShellLink Shortcut: System.SysUtils.DateTimeToString(ts, 'yymmddhhnnsszzz', Now); ThisTempLnkFile := System.SysUtils.IncludeTrailingBackslash(System.IOUtils.TPath.GetTempPath) + ts + '.lnk'; if JclShell.ShellLinkCreate(AShellLink, ThisTempLnkFile) = Winapi.Windows.S_OK then begin // get the MD5 hash of the temporary ShellLink Shortcut (to compare it later with the target hash): SourceHash := GetHashFromFile(ThisTempLnkFile); end else begin MessageDlg('Could not create a temporary ShellLink Shortcut', mtError, [mbOK], 0); EXIT; end; // MOVE the temporary ShellLink Shortcut to the real target: // https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd ThisParams := '/C move ' + '"' + ThisTempLnkFile + '"' + ' ' + '"' + AFile + '"'; Result := JclShell.ShellExecAndWait('cmd.exe', ThisParams, 'runas', SW_HIDE); if not Result then EXIT; //OR: Winapi.ShellAPI.ShellExecute(0, 'runas', 'cmd.exe', PChar(ThisParams), '', Winapi.Windows.SW_HIDE); // Check whether the target file exists: if not FileExists(AFile) then EXIT; // Compare the MD5 hashes of the source file and of the target file: TargetHash := GetHashFromFile(AFile); Result := SameText(SourceHash, TargetHash); end;
-
Put the caret on a source code line containing the URL of a web page: Then press Alt+T -> U to run this IDE tool Open URL From Current Line: Here is the source code: program OpenUrlFromCurrentLine; {$APPTYPE CONSOLE} {$R *.res} uses Winapi.Windows, Winapi.ShellAPI, System.Classes, System.RegularExpressions, System.SysUtils; var ThisLine: Integer; ThisLineStr, ThisURL: string; ThisSource: TStringList; begin // This is explained at: https://en.delphipraxis.net/ try if ParamCount > 0 then begin if ParamCount = 2 then begin if FileExists(ParamStr(1)) then begin if System.SysUtils.TryStrToInt(ParamStr(2), ThisLine) then begin ThisSource := TStringList.Create; try ThisSource.LoadFromFile(ParamStr(1)); if ThisSource.Count >= (ThisLine) then begin ThisLineStr := ThisSource[ThisLine - 1]; ThisURL := TRegEx.Match(ThisLineStr, '\b(?:(?:https?|ftp|file)://|www\.|ftp\.)[-A-Z0-9+&@#/%=~_|$?!:,.]*[A-Z0-9+&@#/%=~_|$]', [roIgnoreCase]).Value; if ThisURL <> '' then Winapi.ShellAPI.ShellExecute(0, 'open', PChar(ThisURL), nil, nil, SW_SHOW); end; finally ThisSource.Free; end; end; end; end; end; //Readln; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. Build it. Then create a new IDE tool and configure it like this: Now you are ready to have fun. Merry Christmas!
-
This has nothing to do directly with JclShell, but it adds useful functionality to the demo app: Since ShellLink Shortcuts are often created in protected locations such as in StartMenu directories or on a Desktop (e.g. "C:\Users\Public\Desktop") I have added a routine which automatically saves the ShellLink Shortcut with Administrator rights if the saving with normal user rights fails: procedure TformMain.SaveShortcutShellLink(const AFile: string); var SL: JclShell.TShellLink; HR: Integer; begin SL.Target := 'C:\Windows\System32\notepad.exe'; // Uncomment the following code line to include the modifier keys in the saved ShellLink Shortcut: SL.HotKey := Winapi.Windows.MakeWord(Byte(HotKey1.HotKey), Byte(HotKey1.Modifiers)); // other ShellLink properties: SL.Description := 'My description'; HR := JclShell.ShellLinkCreate(SL, AFile); if HR <> Winapi.Windows.S_OK then SaveShortcutShellLinkAsAdministrator(AFile, SL); end; procedure TformMain.SaveShortcutShellLinkAsAdministrator(const AFile: string; AShellLink: JclShell.TShellLink); var ts, ThisTempLnkFile, ThisParams: string; ThisShellExecExResult: Boolean; begin System.SysUtils.DateTimeToString(ts, 'yymmddhhnnsszzz', Now); ThisTempLnkFile := System.SysUtils.IncludeTrailingBackslash(System.IOUtils.TPath.GetTempPath) + ts + '.lnk'; JclShell.ShellLinkCreate(AShellLink, ThisTempLnkFile); // https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd ThisParams := '/C move ' + '"' + ThisTempLnkFile + '"' + ' ' + '"' + AFile + '"'; ThisShellExecExResult := JclShell.ShellExecEx('cmd.exe', ThisParams, 'runas', SW_HIDE); //Winapi.ShellAPI.ShellExecute(0, 'runas', 'cmd.exe', PChar(ThisParams), '', Winapi.Windows.SW_HIDE); end;
-
But even much simpler would be: procedure TformMain.LoadShortcutShellLink(const AFile: string); var SL: JclShell.TShellLink; begin JclShell.ShellLinkResolve(AFile, SL); HotKey1.HotKey := SL.HotKey_; end; Andreas, could you please implement this in JclShell. Thank you! And also the opposite conversion should be done internally in JclShell. In this way, the user would not have to do any conversions himself: procedure TformMain.SaveShortcutShellLink(const AFile: string); var SL: JclShell.TShellLink; HotKeyModifiers: Byte; begin SL.Target := 'C:\Windows\System32\notepad.exe'; SL.HotKey_ := HotKey1.HotKey; JclShell.ShellLinkCreate(SL, AFile); end; For this, the declaration of JclShell.TShellLink.Hotkey needs to be set to TShortcut. This really is a bug in JclShell. To make this compatible to existing code, I would redeclare the TShellLink record in JclShell in this way: // Shortcuts / Shell link type PShellLink = ^TShellLink; TShellLink = record Arguments: string; ShowCmd: Integer; WorkingDirectory: string; IdList: PItemIDList; Target: string; Description: string; IconLocation: string; IconIndex: Integer; HotKey: Word; // Use ShellLinkShortCut() to convert it to a TShortCut or simply use: HotKey_: TShortCut; end;
-
This is the new code added by Andreas to JclShell: function ShellLinkShortCut(const Link: TShellLink): TShortCut; type THotKeyModifiers = set of (hkShift, hkCtrl, hkAlt, hkExt); var Modifiers: THotKeyModifiers; begin if Link.HotKey = 0 then Result := scNone else begin Modifiers := THotKeyModifiers(HiByte(Link.HotKey)); Result := LoWord(LoByte(Link.HotKey)); if hkShift in Modifiers then Result := Result or scShift; if hkCtrl in Modifiers then Result := Result or scCtrl; if hkAlt in Modifiers then Result := Result or scAlt; end; end; This reduces the code in my demo app to load the ShellLink Shortcut to: procedure TformMain.LoadShortcutShellLink(const AFile: string); var SL: JclShell.TShellLink; begin JclShell.ShellLinkResolve(AFile, SL); HotKey1.HotKey := JclShell.ShellLinkShortCut(SL); end;
-
Congratulations, Andreas is a very fast guy! Thanks, Andreas!
-
How would you resolve this "handling error"?
-
I have tried to report the bug here: https://issuetracker.delphi-jedi.org/bug_report.php ...but I got this error message: This page isn’t working issuetracker.delphi-jedi.org is currently unable to handle this request. HTTP ERROR 500
-
F6 Search feature does not work anymore?
PeterPanettone replied to PeterPanettone's topic in Delphi IDE and APIs
It was already disabled: Right now, IDE Insight Search (F6) does work (even after IDE restart). Let's wait until it gets disabled again.