Variants
If you know that dialog window's handle already then there are at least 2 variants:
- finding the control by going through the children hierarchy, using
FindWindowEx()
- relying on the dialog template's IDs, using
GetDlgItem()
Both may work out great, but are at the same time fragile, since the dialog window's structure (as per its controls and IDs) can change even by Service Packs already, let alone entire Windows versions. My experience here is from Win2000 up to Win7 and on those systems it worked.
Dialog versions
What you posted as screenshot is the "Vista" version of the dialog; the older "Win95" version is identical in terms of accessing the "filename" ComboBox.
The old one is typical for having the buttons ("open" and "cancel") in one row. Older software might still use these, but your web browser most likely not:

The one since Vista has its buttons in one line and is notable of featuring a full folder pane:

But both pictures show that the control layout is the same: a ComboBoxEx32
is a direct child of the window, having its own child(s). So we can use the same code for both versions.
Code
var
hDialog, hCbx32, hCbx, hEdit, hFilename: HWND;
sText: String;
begin
hDialog:= 9568854; // Dialog window, class "32770"
sText:= 'M:\my\filename.ext'; // What should be set
// Variant #1: finding the control by parents and childs.
// Luckily both the old dialog up to XP and the new dialog
// since Vista do not differ as per the filename ComboBox.
hCbx32:= FindWindowEx( hDialog, 0, 'ComboBoxEx32', nil ); // Most likely the 3rd child control
hCbx:= FindWindowEx( hCbx32, 0, 'ComboBox', nil ); // Actual ComboBox inside that
hEdit:= FindWindowEx( hCbx, 0, 'Edit', nil ); // Edit control inside ComboBox
SendMessage( hEdit, WM_SETTEXT, 0, LPARAM(PChar(sText)) );
// Variant #2: using dialog template IDs, which haven't
// changed since XP with one of its Service Packs. However,
// tested with Win7 only.
hFilename:= GetDlgItem( hDialog, $47C ); // "cmb13", found at least in XP SP3
if hFilename= 0 then hFilename:= GetDlgItem( hDialog, $480 ); // "edt1" = Maybe prior to XP without any SP
SendMessage( hFilename, WM_SETTEXT, 0, LPARAM(PChar(sText)) );
end;
One of both variants should do already. Successfully tested on Win7x64
- using Paint's "Open" command for the Vista dialog version, and
- one of my older program's "Open" command for the Win95 dialog version:
the text in the filename's ComboBox was set as expected.