This code was posted by someone else earlier and I also wondered the
same question but missed the reply...
---------
I have been trying to use the GetFileOpen 32 bit version using the
windows 32DLL call program Call32NT which is available may places.
Almost every 32 bit call I try works except GetFileOpen yet the
documentation says I am calling it correct (sample code below)
anyone have any ideas on why it fails...
USES Strings, WinTypes, WinProcs, CommDlg, Call32NT;
const
OFN_READONLY = $00000001;
OFN_OVERWRITEPROMPT = $00000002;
OFN_HIDEREADONLY = $00000004;
OFN_NOCHANGEDIR = $00000008;
OFN_SHOWHELP = $00000010;
OFN_ENABLEHOOK = $00000020;
OFN_ENABLETEMPLATE = $00000040;
OFN_ENABLETEMPLATEHANDLE = $00000080;
OFN_NOVALIDATE = $00000100;
OFN_ALLOWMULTISELECT = $00000200;
OFN_EXTENSIONDIFFERENT = $00000400;
OFN_PATHMUSTEXIST = $00000800;
OFN_FILEMUSTEXIST = $00001000;
OFN_CREATEPROMPT = $00002000;
OFN_SHAREAWARE = $00004000;
OFN_NOREADONLYRETURN = $00008000;
OFN_NOTESTFILECREATE = $00010000;
OFN_NONETWORKBUTTON = $00020000;
OFN_NOLONGNAMES = $00040000;
OFN_EXPLORER = $00080000;
OFN_NODEREFERENCELINKS = $00100000;
OFN_LONGNAMES = $00200000;
VAR
W32GetOpenFileName: Function (Var OpenFN: TOpenFileName; Id:
LongInt): LongBool;
VAR CallRes: Boolean; id_W32GetOpenFileName: LongInt; FileName: String;
OpenFN: TOpenFileName; Filter: Array [0..100] Of Char;
BEGIN
FillChar(Filter, SizeOf(Filter), #0);
StrCopy(Filter, 'All files');
StrCopy(@Filter[StrLen(Filter)+1], '*.*'+#0);
FillChar(OpenFN, SizeOf(OpenFN), #0);
with OpenFN do
begin
hInstance := 0;
hwndOwner := 0;
lpstrFilter := @Filter;
lpstrFileTitle:= @FileName[1];
flags := ofn_FileMustExist OR ofn_LongNames OR
ofn_HideReadOnly;
lStructSize := SizeOf(OpenFN);
nFilterIndex := 1;
nMaxFile := 255;
end;
If (GetWinFlags AND $6000 <> 0) Then Begin { Win NT/95 check
@W32GetOpenFileName := @Call32; { Init 32 bit call
id_W32GetOpenFileName := Declare32(
'GetOpenFileNameA', 'comdlg32', 'p'); { Create reference
If NOT Call32NTError Then Begin { Check 32 bit
error }
CallRes := W32GetOpenFileName(OpenFN, id_W32GetOpenFileName) {
This doesn't sob!!!!!!! }
End Else CallRes := GetOpenFileName(OpenFN); { Call 16 bit }
End Else CallRes := GetOpenFileName(OpenFN); { Call 16 bit }
GetOpenFilename(OpenFN); { 16 bit open this
works!!!!! }
END.
---------
If someone can reply with the working code, that would be awesome...
Thanx, Mechanix