On 11/10/2005 5:43:32 PM, Ian Binnie wrote:
>On 11/10/2005 2:57:32 PM, Christian Ziemski wrote:
>>
>>>Maybe it's possible to find out details of the problematic call by
>>>looking at WinSCP's sourcecode. It's written in Borland C++ Builder
>>>version 6 (from readme file).
>>
>>The call of the external >editor is in the file
>>winscp376source\forms\CustomScpExplorer.cpp
>>and the then used ExecuteShell is in the file
>>winscp376source\windows\GUITools.cpp
>>
>>
>Unfortunately you need more than some knowledge of C++.
>The function is not in Microsoft SDK, so it is probably a Borland proprietary function.
As far as I can see the following are the relevant parts:
if (ExecuteFileBy == efInternalEditor)
{
// .......
}
else
{
HANDLE Process;
if (ExecuteFileBy == efExternalEditor)
{
AnsiString Program, Params, Dir;
Data.Command = ExternalEditor->Data.ExternalEditor;
TWinConfiguration::ReformatFileNameCommand(Data.Command);
SplitCommand(Data.Command, Program, Params, Dir);
assert(Params.Pos(ShellCommandFileNamePattern) > 0);
Params = StringReplace(Params, ShellCommandFileNamePattern,
AddPathQuotes(FileName), TReplaceFlags() << rfReplaceAll);
if (!ExecuteShell(Program, Params, Process))
{
throw Exception(FMTLOAD(EDITOR_ERROR, (Program)));
}
}
else
{
assert(Side == osRemote);
if (!ExecuteShell(FileName, "", Process))
{
throw Exception(FMTLOAD(EXECUTE_FILE_ERROR, (FileName)));
}
}
//---------------------------------------------------------------------------
bool __fastcall ExecuteShell(const AnsiString Path, const AnsiString Params)
{
return ((int)ShellExecute(NULL, "open", (char*)Path.data(),
(char*)Params.data(), NULL, SW_SHOWNORMAL) > 32);
}
//---------------------------------------------------------------------------
bool __fastcall ExecuteShell(const AnsiString Path, const AnsiString Params,
HANDLE & Handle)
{
bool Result;
TShellExecuteInfo ExecuteInfo;
memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
ExecuteInfo.cbSize = sizeof(ExecuteInfo);
ExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ExecuteInfo.hwnd = Application->Handle;
ExecuteInfo.lpFile = (char*)Path.data();
ExecuteInfo.lpParameters = (char*)Params.data();
ExecuteInfo.nShow = SW_SHOW;
Result = (ShellExecuteEx(&ExecuteInfo) != 0);
if (Result)
{
Handle = ExecuteInfo.hProcess;
}
return Result;
}
//---------------------------------------------------------------------------
And ShellExecute() is a Windows call, isn't it?
(I'm not a programmer at this level!!)
Christian