ShellExecute & print problem 
Author Message
 ShellExecute & print problem

there's a simple code:

#include <stdio.h>
#include <windows.h>
#include <shellapi.h>
int main(int argc, char* argv[])
{
 int res;
    if (argc != 2) return -1;

 res = (int)ShellExecute(NULL, "print", argv[1], NULL, "C:\\", SW_HIDE);

 if (res <= 32) return res;

 return 0;

Quote:
}

easy & nice.
I try to print *.rtf files. because *rtfs are connected with Word (when
there's MSWord installed), OS will pass this task to MSWord. and it does so.

under Windows 2000 Word shows for a moment and then it closes. task is
complete.

under Windows 98 Word shows and prints the document but doesn't close. it
just hangs for a few seconds and then tells "This task lasted longer than
expected. Do you still want to continue the task?" (I've got localized
version so I translated my message, it can be a little different). this is
not what I would like to have.

question: what can be the cause? should I call anything else after or before
ShellExecute() or maybe it's an unexpected behaviour of ShellExecute() &
Word?

thanks in advance for any help.

Wiktor



Tue, 04 May 2004 16:38:35 GMT  
 ShellExecute & print problem

Quote:
> there's a simple code:

> #include <stdio.h>
> #include <windows.h>
> #include <shellapi.h>
> int main(int argc, char* argv[])
> {
>  int res;
>     if (argc != 2) return -1;

>  res = (int)ShellExecute(NULL, "print", argv[1], NULL, "C:\\", SW_HIDE);

>  if (res <= 32) return res;

>  return 0;
> }
> under Windows 98 Word shows and prints the document but doesn't close.

That's because ShellExecute() uses DDE to communicate with WORD. DDE uses
Windows messages. Your program doesn't pump messages. Switch to
ShellExecuteEx() and specify the flag SEE_MASK_FLAG_DDEWAIT.

I don't know why it works on NT though I'm glad it does. :-)

Regards,
Will



Wed, 05 May 2004 01:41:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Printing Problems (how to print, pause printing, then print more)

2. Using ShellExecute to print

3. ShellExecute & properties

4. Using ShellExecute & Browsers

5. Problem printing out graphics & text

6. Windows 2000 & Rich Edit Printing problem

7. Rich Edit Control Printing Problem (like the print preview problem)

8. Different results between Print & Print Preview

9. Question : Print & Print Preview Page Numbers

10. shellexecute problem

11. problem with ShellExecute

12. ShellExecute and Windows 2000 problem

 

 
Powered by phpBB® Forum Software