• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

Using Open With Dialog

Hi All!

There is an dialog in Windows called 'Open With'. It is not supported by Delphi and there is no information about it into MSDN. My question: How to use this dialog in my application in order to give user a way to open document thru this dialog for choosing application.

Jo.
0
Fatman121898
Asked:
Fatman121898
1 Solution
 
shenqwCommented:
listening
0
 
BoRiSCommented:
Fatman

I seem to remember playing with this a while ago, but never really got anywhere, one place to look is the IShellBrowser ot IShellExecute I think it was there that I saw related stuff to the IContextMenu etc...

Hope this helps a little...

Later
BoRiS

0
 
intheCommented:
HI,
you can use it from url.dll
example:


unit UrlAPI;
 
interface
 
uses Windows;
 
function URLAssociationDialogA(
hwndParent: HWND;
  dwInFlags: DWORD;
  pcszFile: PAnsiChar;
  pcszURL: PAnsiChar;
  pszAppBuf: PAnsiChar;
  ucAppBufLen: UINT  ): Integer; stdcall;
 
function URLAssociationDialogW(
hwndParent: HWND;
dwInFlags: DWORD;
  pcszFile: PWideChar;
  pcszURL: PWideChar;
  pszAppBuf: PWideChar;
  ucAppBufLen: UINT ): Integer; stdcall;
 
function URLAssociationDialog(
hwndParent: HWND;
  dwInFlags: DWORD;
  pcszFile: PChar;
  pcszURL: Pchar;
  pszAppBuf: PChar;
  ucAppBufLen: UINT ): Integer; stdcall;
 
 
const
url = 'url.dll';
URLASSOCDLG_FL_USE_DEFAULT_NAME  = $0001;
URLASSOCDLG_FL_REGISTER_ASSOC    = $0002;
 
implementation
 
function URLAssociationDialogA; external url name 'URLAssociationDialogA'; function URLAssociationDialogW; external url name 'URLAssociationDialogW'; function URLAssociationDialog; external url name 'URLAssociationDialogA';
 
 
end.





unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,   StdCtrls, UrlAPI;

type
  TForm1 = class(TForm)
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
hwndParent : integer;
  dwInFlags : dword;
pcszFile : string;
pcszURL : string;
  pszAppBuf : array[0..255]of char;
  ucAppBufLen : integer;
begin
with opendialog1 do begin
  if (execute) then begin
  hwndParent := self.handle;
  pcszFile := filename;
  //pcszURL := 'file://c|/windows/notepad.exe';
  pcszURL := 'file://C|/Program Files/Microsoft Office/Office/excel.exe';
  ucAppBufLen := sizeof(pszAppBuf);
  URLAssociationDialog(
    hwndParent,
    URLASSOCDLG_FL_REGISTER_ASSOC,
    pchar(pcszFile),
    pchar(pcszURL),
    @pszAppBuf,
    ucAppBufLen);
  end;{if}
end;{with}
end;

end.



Regards Barry
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ptmcompCommented:
On WinNT4 and Win95 that was just a DLL call (you found it in the registry (look for "open with" and what's written in it's command line). But now (on W2k) this is a COM interface and I don't know how to get that.
Regards, ptm.
0
 
ptmcompCommented:
When you have found it, please put the line here. I'll test it on Win2k.
0
 
Fatman121898Author Commented:
It works. Thanks, Barry!
Ptcomp, Barry found it.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now