ShellExecute to open a file: Is there alternative?

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

ShellExecute to open a file: Is there alternative?

Postby arjfca » 01 Sep 2016

Hello

Is there another way to open a Windows file than this one: shellexecute("open",text(path_and_FileName));

I'm using ShellExecute to open a file. It use to work, but fail to work since this morning.

I had similar intermittent problem with the function. The code do check if the file exist. If not then created it. But, it won't open it

Martin

Code: Select all

//OpenNotesFile will iopen a text file to write notes

Input: FileName (stringsimple);
var:

Path_and_FileName ("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\" + FileName + ".txt");
//print (Path_and_FileName);
//File_Name = "G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\EUR.JPY_Chart_3.txt";

iF ELC.PathExists(Path_and_FileName) then begin
shellexecute("open",path_and_FileName);
end
else begin
//Print(Path_and_FileName);
FileAppend(Path_and_FileName,"Note for: " + filename + NEWLINE +">" + NEWLINE + ">");
shellexecute("open",text(path_and_FileName));
end;

Code: Select all

DEFINEDLLFUNC: "shell32.dll", int, "ShellExecuteA",
lpstr, // HWND
LPSTR, // lpOperation,
LPSTR, // lpFile,
LPSTR, // lpParameters,
LPSTR, // lpDirectory,
INT // nShowCmd
;

Input:
operation(StringSimple)
{
"edit" - Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.
"explore" - Explores a folder specified by lpFile.
"find" - Initiates a search beginning in the directory specified by lpDirectory.
"open" - Opens the item specified by the lpFile parameter. The item can be a file or folder.
"print" - Prints the file specified by lpFile. If lpFile is not a document file, the function fails.
},

lpFile(StringSimple);

ShellExecute = ShellExecuteA("", operation, lpFile, "", "", 0);

Return to “MultiCharts”