unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure OpenDialog1SelectionChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure EnableFileName(H,P: HWND);
var
hc: HWND;
buf: array[Byte] of Char;
begin
h := GetWindow(h, GW_HWNDFIRST);
while h <> 0 do
begin
hc := GetWindow(h, GW_CHILD);
while hc <> 0 do
begin
GetClassName(hc, buf, SizeOf(buf));
if buf = 'ComboBox' then
begin
GetWindowText(hc,buf,MAX_PATH);
if buf='可执行文件' then
begin
EnableWindow(hc, False);
Exit;
end;
end;
hc := GetWindow(hc, GW_HWNDNEXT);
end;
h := GetWindow(h, GW_HWNDNEXT);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
OpenDialog1.Filter:='可执行文件|*.exe';
OpenDialog1.OptionsEx := [ofExNoPlacesBar];//去掉左栏
if OpenDialog1.Execute then
begin
ShowMessage(OpenDialog1.FileName);
end;
end;
procedure TForm1.OpenDialog1SelectionChange(Sender: TObject);
begin
EnableFileName(Self.Handle,Self.Handle);
end;
end.
600) this.width = 600;">