Board index » delphi » 32 Bit DLL call to Comdlg32.dll in Win 95

32 Bit DLL call to Comdlg32.dll in Win 95

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.

 

Re:32 Bit DLL call to Comdlg32.dll in Win 95


Quote
ldeb...@ibm.net wrote in message <354829f...@news1.ibm.net>...
>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...

You missed a very important point: 16-bit Windows expect adresses to be
in the form (Selector:Offset), where 32-bit Windows expect adresses to
be in the form (flat address)
When mixing 16-bit with 32-bit calls, all memory adresses must be
converted.
Call32NT is -if I remember correctly- an implementation of the Generic
Thunk. In this case, an address conversion API is available. This
function is called GetVDMPointer32W. Check Call32NT, a function like
this should be available.

[snip]

Quote
>   W32GetOpenFileName: Function (Var OpenFN: TOpenFileName; Id:

LongInt): LongBool;

[snip]

Quote
>  FillChar(OpenFN, SizeOf(OpenFN), #0);
>  with OpenFN do
>  begin
>    hInstance     := 0;
>    hwndOwner     := 0;
>    lpstrFilter   := @Filter;
>    lpstrFileTitle:= @FileName[1];

So, try adjusting these two lines

Can you tell me if it works?
--
Zweitze de Vries
zweitze<at>iname<dot>com
When replying, please adjust reply address

Other Threads