Answer the question
In order to leave comments, you need to log in
Why won't WinExec open the exe program Windows 7 (64 Bit) error 2?
/+------------------------------------------------ ------------------+
//|
//|
//| https://www.mql5.com |
//+----------------------------------------------- -------------------+
//+--------------------- ------------------------------------+
//| template.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| www.metaquotes.net |
//+----------------------------------------------- --------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link " www.metaquotes.net "
//---- function import from external DLL
#import "kernel32.dll"
int WinExec(string lpCmdLine,int uCmdShow);
#import
//---- opening\show constants (uCmdShow parameter)
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_FORCEMINIMIZE 11
#define SW_MAX 11
//+--------------------------- ------------------------------------+
//| script program start function |
//+----------------------------------------------- -------------------+
int start()
{
//----
WinExec("C:\\AlertMailer.exe",1);
//----
return(0);
}
Answer the question
In order to leave comments, you need to log in
I am a shrimp. Here's why it doesn't work: you decided to abandon the standard Windows headers and incorrectly specified the calling convention.
#include <windows.h>
int WINAPI WinExec(string lpCmdLine,int uCmdShow);
#include <windows.h> // убирай этот kernel32.dll
STARTUPINFO si;
PROCESSINFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.wShowWindow = SW_SHOWDEFAULT;
CreateProcess(NULL, L"c:\\AlertMailer.exe", NULL, NULL, false, 0, NULL, NULL, &si, &pi);
// Мы не ждём ничего от программы — шшас закроем.
// Если хотите дождаться — WaitForSingleObject(hProcess, INFINITY);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
);
Note This function is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function.
Because ERROR_FILE_NOT_FOUND - 2 (0x2) - The system cannot find the file specified.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question