Synchronous or asynchronous execution of a DLL

Hi.

I encounter a problem with the following DLL :

#include <windows.h>
#include <string>

using namespace std;

void __stdcall MYFUNCTION(long anynumber)

{

SHELLEXECUTEINFOA command1;
ZeroMemory (&command1, sizeof (SHELLEXECUTEINFOA));
command1.cbSize = sizeof (SHELLEXECUTEINFOA);
command1.lpVerb = "open";
command1.lpFile = string1;
command1.lpParameters = string2;
command1.nShow = SW_HIDE;
command1.fMask = SEE_MASK_NOCLOSEPROCESS;
ShellExecuteExA(&command1);
WaitForSingleObject(command1.hProcess, INFINITE);

}

This DLL calls a program (MyProgram.exe) whose full path name is provided in 'string1'. MyProgram reads a file whose full path name is provided in 'string2' and creates a file whose name is also provided in 'string2'.
The output file is further exploited in the program calling the DLL.

Everything works fine but based on the results found after exploitation of the output file, I see that there is some delay in the values provided by the DLL.
I have got the feeling that the DLL gives control back to the calling program before MyProgram.exe is finished.

So my question is : does this DLL executes 'synchronously'? Stated otherwise, is control given back to the DLL (and thus also to the program calling this DLL) only after MyProgram.exe is finished? If not, what should be changed in order to have the DLL not give control back to the calling program before MyProgram.exe is finished?

Thanks in advance for your help.
My English is poor. So...

First, you have coded: "WaitForSingleObject(command1.hProcess, INFINITE);" this make your DLL wait for the "MyProgram" to exit. Also, the parameters you used in open the target file have some affect on the result. You can check out the MSDN on create file. The file sharing mode.
Hi hbq0449.

Thank you for your advice.

Do you mean that working with files in MyProgram.exe might be the cause of the delay?
Topic archived. No new replies allowed.