I would like to make changes to this DLL in order to call it from programs that store strings in Unicode format.
I guess I should use the 'W' form of the orders, something like :
The parameter string1 holds something like "C:\\MyProgram.exe" and string2 holds some parameters to be used by MyProgram.exe.
When the DLL is called, MyProgram.exe should create some files. When used with parameters as described in the stdcall statement, no files are created. It looks like the string string1 (and probably also string2) are not meaningful for the SHELLEXECUTEINFO statement.
Note that the same problems occur with the other codings proposed for the string1 and string2 strings in the stdcall statement (char *, LPWSTR, LPCWSTR).
Here is the version of the DLL that works (Strings are hardcoded, so no parameters are to be passed to the DLL) :
When control is returned to the calling program, it is seen that MyProgram.exe has created the expected files.
I think that the problem occurs at the level of the strings (the calling program stores the strings in Unicode format) but I am not able to debug this problem.
Unfortunately inserting this code prevents me from compiling the DLL successfully. I get a lot of error messages like :
1>MyFunctionDLL.cpp(37): error C2079: 'file' uses undefined class 'std::basic_ofstream<char,std::char_traits<char>>'
1>MyFunctionDLL.cpp(37): error C2440: 'initializing': cannot convert from 'initializer list' to 'int'
1>MyFunctionDLL.cpp(37): note: The initializer contains too many elements
1>MyFunctionDLL.cpp(38): error C2228: left of '.write' must have class/struct/union
1>MyFunctionDLL.cpp(38): note: type is 'int'
1>MyFunctionDLL.cpp(39): error C2228: left of '.write' must have class/struct/union
1>MyFunctionDLL.cpp(39): note: type is 'int'
1>MyFunctionDLL.cpp(40): error C2228: left of '.close' must have class/struct/union
1>MyFunctionDLL.cpp(40): note: type is 'int'
Correcting those compilation errors is far above the level of my skills in C++.
This last update led to compilation errors I wasnot able to correct.
However, based on some items in a forum, I made some changes to the DLL, in order to check if parameters (strings) were correctly passed to the DLL. The puropose of these added statements was to show that the way the calling program (Metatrader) stores the strings is not the same as in C : before the string is a 4-bytes integer housing the length of the string :
Metatrader is a trading platform. Thus the documentation is mainly related to the development of indicators and Expert Advisors (kind of robots executing buy/sells orders automatically). Documentation is rather weak about internals and language.
The problem with Metatrader is that the internals are sometimes changed is an abrupt way (to say the least). For instance, from a specific build, strings that were previously stored in ASCII format were now stored in Unicode format. This caused all users having implemented DLL using strings to face severe problems with their DLLs.
The DLL that I tried "convert' to Unicode is also used on another trading Platform (TradeStation) that stores the strings in ASCII format and the DLL works perfectly (using SHELLEXECUTEA and the 'A' version of the other verbs).
Can you tell me how I should modify the DLL in order to check the return value of ShellExecuteExW?