Solved

Using Open With Dialog

Posted on 2000-05-12
6
396 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi IDE crash without error message ... 7 99
Find and Replace Stream with 0s 8 69
Breakpoint doesn't stop in my variable 3 30
MS Access from Delphi 31 60
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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