Jump to content

ShellExecute and OpenProcess on Excel


Recommended Posts

Hi,

I have this problem that I have been fighting with for last few days. Your help would be greatly appreciated. Currently, I am trying to migrate an application from an NT box to a Windows2003 box that has Ofiice XP loaded. The application writes into an Excel .csv file, opens it, then opens another Excel template file with macros. It then waits for the template macros to be done processing and ends. But it is not working on Windows2003. I also tried to run it on windows200 with both Office 97 and Office XP but the result is the same. Here are the symptoms.

1. szTmp = szTmplDir + "afile.csv";

pid = ShellExecute(NULL, "open", szTmp, NULL, szArchDir, SW_SHOWNA);

It opens the file successfully. But...

2. DWORD dw = GetLastError();

CHAR szBuf[80];

sprintf(szBuf, "failed: GetLastError returned %u\n", dw);

this returns an error code 126 (ERROR_MOD_NOT_FOUND).

3. HINSTANCE pid;

hXl = OpenProcess(PROCESS_ALL_ACCESS, false, (int)pid);

if (hXl == NULL)

printf("Openprocess failed\n");

OpenProcess returns NULL.

4. dw = GetLastError();

sprintf(szBuf, "failed: GetLastError returned %u\n", dw);

This returns an error code 87 (ERROR_INVALID_PARAMETER)

Please please help...

Thanks...

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...