$theTitle=wp_title(" - ", false); if($theTitle != "") { ?>
About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like
In my SATA Controller Identification tool I was using the TSaveDialog (Delphi 2010) but I got a report that under Windows PE the dialog is never shown.
There’s no exception and I didn’t really bother to check why it fails. Instead I decided to replace it with the GetSaveFileName API which does work under Windows PE.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | var sl: TStringList; ofn: OPENFILENAME; Buf: array[0..MAX_PATH] of Char; ZeroMemory(@ofn, SizeOf(ofn)); ofn.lStructSize := SizeOf(ofn); ofn.hWndOwner := Form1.Handle; ofn.lpstrFile := @Buf[0]; ofn.nMaxFile := Length(Buf); ofn.lpstrInitialDir := PChar(GetCurrentDir); ofn.lpstrFilter := 'Any File'#0'*.*'#0'Registry file'#0'*.reg'#0#0; ofn.nFilterIndex := 0; ZeroMemory(@Buf, SizeOf(Buf)); if GetSaveFileName(ofn) then begin // Buf now contains the filename end; |
4 Responses for "Delphi TSaveDialog doesn’t work on Windows PE"
Hi Remko,
Delphi 2007 and up use the “IFileOpenDialog” and “IFileSaveDialog” interfaces on Vista and better (including Windows PE 2 and up) when using the common dialogs. Windows PE does not support this interface.
To use the old style dialogs in programs written with Delphi 2007 and up define “UseLatestCommonDialogs := false” before calling “TOpenDialog.Execute” or “TSaveDialog.Execute”. This makes “TOpenDialog” and “TSaveDialog” work on Windows PE.
Regards, Olaf
To add to my previous post: Windows PE 4 (the version that ships with Windows 8) now includes (optional) support for the .NET Framework. If a WinForms application running on Windows PE calls “OpenFileDialog.ShowDialog” or “SaveFileDialog.ShowDialog” the call fails unless one sets the property “AutoUpgradeEnabled” to “false” before calling “ShowDialog”.
Regards, Olaf
Thanks Olaf, it works
Olaf, you saved me with AutoUpgradeEnabled = $false. Thanks a ton!
Leave a reply