To access the 64-bit System folder from a 32-bit process, you should use the special ”SysNative" alias instead of the ”System32" folder directly:
PChar('C:\Windows\SysNative\msconfig.exe')
If you need to support 32-bit OS versions or 64-bit compiling, use IsWow64Process()
to detect if your app is running under WOW64:
{$IFDEF WIN64}
function IsWow64: Boolean;
begin
Result := False;
end;
{$ELSE}
function IsWow64Process(hProcess: THandle; out Wow64Process: BOOL): BOOL; stdcall; external 'kernel32.dll' delayed;
function IsWow64: Boolean;
var
Ret: BOOL;
begin
Result := False;
// XP = v5.1
if (Win32MajorVersion > 5) or
((Win32MajorVersion = 5) and (Win32MinorVersion >= 1)) then
begin
if IsWow64Process(GetCurrentProcess(), Ret) then
Result := Ret <> 0;
end;
end;
{$ENDIF}
var
errorcode: integer;
SysFolder: string;
begin
If IsWow64 then
SysFolder := 'SysNative'
else
SysFolder := 'System32';
errorcode := ShellExecute(0, 'open', PChar('C:\Windows\'+SysFolder'+\msconfig.exe'), nil, nil, SW_NORMAL);
if errorcode <= 32 then
ShowMessage(SysErrorMessage(errorcode));
end;