Solved

Using Open With Dialog

Posted on 2000-05-12
6
388 Views
Last Modified: 2010-04-04
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
Comment
Question by:Fatman121898
6 Comments
 
LVL 3

Expert Comment

by:shenqw
ID: 2803817
listening
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 2803924
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
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 2806001
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 10

Expert Comment

by:ptmcomp
ID: 2806065
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
 
LVL 10

Expert Comment

by:ptmcomp
ID: 2806068
When you have found it, please put the line here. I'll test it on Win2k.
0
 
LVL 1

Author Comment

by:Fatman121898
ID: 2813987
It works. Thanks, Barry!
Ptcomp, Barry found it.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now