Delphi/Shellexecute

Advertisement


Question
Hello Randy,

My program uses a button to make the Windows OnScreen Keyboard available to users.
The code I use is
Shellexecute(handle,'open','osk.exe','',nil,sw_shownormal);

This works fine in Windows 7 32bit and previous versions.
It doesn't work in Windows 7 64 bit and Windows 8.
Any ideas why?
Thanks
Michael

Answer
Michael,

The issue is you can't call a 64 bit app from a 32 bit app.  Here is a work-around:

function Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection: BOOL): BOOL; stdcall;

implementation

uses
 ShellAPI;

{$R *.dfm}

function Wow64EnableWow64FsRedirection; external kernel32 name 'Wow64EnableWow64FsRedirection';

procedure TForm2.Button1Click(Sender: TObject);
begin
 Wow64EnableWow64FsRedirection(False);
 try
   Shellexecute(0{handle}, 'open', 'osk.exe', '', nil, sw_shownormal);
 finally
   Wow64EnableWow64FsRedirection(True);
 end;
end;

Delphi

All Answers


Answers by Expert:


Ask Experts

Volunteer


Randy Sill

Expertise

Turbo Pascal and Delphi developer since 1986. Strengths - UI, Windows API, Database, SQL, Internet, Threading, NT Services.

Experience

Turbo Pascal and Delphi developer since 1986.

Education/Credentials
Delphi 5 Certification, Borland

Awards and Honors
2005 Indiana IT/Software Million Dollar Award, Key Technical Contributor

©2016 About.com. All rights reserved.