32Bit / 64Bit 프로그램의 윈도우 시스템 폴더 프로그램 실행시 해결 방법
Solution #1]
{$APPTYPE CONSOLE}uses ShellAPi, SysUtils; Function Wow64DisableWow64FsRedirection(Var Wow64FsEnableRedirection: LongBool): LongBool; StdCall; External 'Kernel32.dll' Name 'Wow64DisableWow64FsRedirection'; Function Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection: LongBool): LongBool; StdCall; External 'Kernel32.dll' Name 'Wow64EnableWow64FsRedirection'; Var Wow64FsEnableRedirection: LongBool; begin try Wow64DisableWow64FsRedirection(Wow64FsEnableRedirection); ShellExecute(0, nil, PChar('C:\Windows\System32\msconfig.exe'), nil, nil, 0); Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
Solution #2]{$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;
[참고 URL]
http://www.borlandforum.com/impboard/impboard.dll?action=read&db=free&no=25126
https://stackoverflow.com/questions/12849939/can-not-get-msconfig-exe-to-run-in-the-system32-folder-shellexecute-delphi