ShellExecuteEx behaviour under Micromacro v1.04.167
Posted: Thu Feb 12, 2015 9:09 am
Hey, I'm doing a Lua launcher for the Rom client to be able to connect to the client
without searching for the process.
As most probably know the client only accepts the NoCheckVersion argument in a
shell link, not on command line.
Now, the behavior is due to the client checking for WinMains's 4th argument (nCmdShow)
being equal to 1. This is typically done with ex. the SHELLEXECUTEINFO structure used in
the ShellExecuteEx call by setting SHELLEXECUTEINFO.nShow = SW_SHOWNORMAL which
is what the symlink does by default.
So, I've created a small program to do just this and return the PID for process identification:
Running this as a standalone .exe file in a command line window starts the client directly without any
updates running.
Using it as a plugin in Lua 5.2 also works as a charm, I can start by shell link or client directly and
it accepts the argument.
But, loading the plugin as a Lua plugin in a Micromacro script fails, the client starts but does not
accept the command line argument so I expect the nCmdShow does not reflect the SW_SHOWNORMAL
set in the call.
I'm banging my head against a wall here, there seem to be something in Micromacro that makes the
ShellExecuteEx call behave differently. My guess is something inherited, like environment but I
havent been able to identify it.
Any1 have ANY ideas on what that could be?
Best regards
DX
without searching for the process.
As most probably know the client only accepts the NoCheckVersion argument in a
shell link, not on command line.
Now, the behavior is due to the client checking for WinMains's 4th argument (nCmdShow)
being equal to 1. This is typically done with ex. the SHELLEXECUTEINFO structure used in
the ShellExecuteEx call by setting SHELLEXECUTEINFO.nShow = SW_SHOWNORMAL which
is what the symlink does by default.
So, I've created a small program to do just this and return the PID for process identification:
Code: Select all
int runLink(char *cmd, char *args, char *dir)
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(ShExecInfo);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = cmd;
ShExecInfo.lpParameters = args;
ShExecInfo.lpDirectory = dir;
ShExecInfo.nShow = SW_SHOWNORMAL;
ShExecInfo.hInstApp = NULL;
if(ShellExecuteExU(&ShExecInfo)){
pid = GetProcessId(ShExecInfo.hProcess);
CloseHandle(ShExecInfo.hProcess);
} else {
DWORD errorCode = GetLastError();
DisplayError(TEXT("Unable to execute."), errorCode);
}
return (int)pid;
}
// Example usage
pid = runLink("C:\\Program Files (x86)\\Runes of Magic\\Client.exe", "NoCheckVersion", "C:\\Program Files (x86)\\Runes of Magic");
pid = runLink("C:\\Program Files (x86)\\Runes of Magic\\ClientRun.lnk", NULL, NULL);
updates running.
Using it as a plugin in Lua 5.2 also works as a charm, I can start by shell link or client directly and
it accepts the argument.
But, loading the plugin as a Lua plugin in a Micromacro script fails, the client starts but does not
accept the command line argument so I expect the nCmdShow does not reflect the SW_SHOWNORMAL
set in the call.
Code: Select all
mmext = require("mmext")
print("PID = ", mmext.Spawn("C:\\Program Files (x86)\\Runes of Magic\\ClientRun.lnk", nil, nil))
ShellExecuteEx call behave differently. My guess is something inherited, like environment but I
havent been able to identify it.
Any1 have ANY ideas on what that could be?
Best regards
DX