Button Event
void Csqlcontestdlg::onok ()
{
CString strpath = "cmd.exe";
if (IsWow64 ())
{
Wow64disablewow64fsredirection (NULL);
}
Startupinfo si = {sizeof (startupinfo)};
ZeroMemory (&si,sizeof (startupinfo));
SI.CB = sizeof (STARTUPINFO);
Si.wshowwindow = Sw_show;
Si.dwflags = Startf_useshowwindow;
Process_information Pi;
memset (&pi,0,sizeof (pi));
if (CreateProcess (NULL, (char*) (LPCSTR) strpath,null,null,false,0,null,null,&si,&pi))
{
}
Block the previous process
while (WaitForSingleObject (pi.hprocess,20))
{
;
}
Wow64revertwow64fsredirection (NULL);
}
/****************************************************/
/* Determine if it is a 64-bit system */
/****************************************************/
typedef BOOL (WINAPI *lpen_iswow64process) (Handle,pbool);
BOOL Csqlcontestdlg::iswow64 ()
{
BOOL bIsWow64 = false;
Lpen_iswow64process fniswow64process;
Fniswow64process = (lpen_iswow64process) GetProcAddress (GetModuleHandle (TEXT ("kernel32")), "iswow64process");
if (NULL! = fniswow64process)
{
if (!fniswow64process (GetCurrentProcess (), &biswow64)) {};
}
return bIsWow64;
}
/****************************************************/
/* If the system is 64-bit, cancel the key position of the file */
/****************************************************/
typedef BOOL (WINAPI *lpen_wow64disablewow64fsredirection) (pvoid* OldValue);
BOOL csqlcontestdlg::wow64disablewow64fsredirection (pvoid* OldValue)
{
BOOL BRet = false;
Lpen_wow64disablewow64fsredirection fnwow64disablewow64fsredirection;
Fnwow64disablewow64fsredirection = (lpen_wow64disablewow64fsredirection)
GetProcAddress (GetModuleHandle (TEXT ("kernel32")), "wow64disablewow64fsredirection");
if (NULL! = fnwow64disablewow64fsredirection)
{
if (Fnwow64disablewow64fsredirection (OldValue))
{
BRet = true;
}
}
return bRet;
}
/****************************************************/
/* If the system is 64-bit, restore the key position of the file */
/****************************************************/
typedef BOOL (WINAPI *lpen_wow64revertwow64fsredirection) (PVOID OldValue);
BOOL csqlcontestdlg::wow64revertwow64fsredirection (PVOID OldValue)
{
BOOL BRet = false;
Lpen_wow64revertwow64fsredirection fnwow64revertwow64fsredirection;
Fnwow64revertwow64fsredirection = (lpen_wow64revertwow64fsredirection) GetProcAddress (GetModuleHandle (TEXT (" Kernel32 "))," wow64revertwow64fsredirection ");
if (NULL! = fnwow64revertwow64fsredirection)
{
if (Fnwow64revertwow64fsredirection (OldValue))
{
BRet = true;
}
}
return bRet;
}
Depending on the operating system (64/32), the settings file runs at 64 bits. also resolves the issue: "Trying to load an incorrect program."