Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

need help with ShellExecute

rahzan
New Contributor I
1,756 Views
Can anyone provide a quick sketch of how to set the structure for ShellExecute and run it?

Thanks in adv.
TimH
0 Kudos
11 Replies
Steven_L_Intel1
Employee
1,756 Views
0 Kudos
rahzan
New Contributor I
1,756 Views
poifect!

Is there a setting so that the execution halts in the caller until the spawned app is finished?

Thank,
Tim
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,756 Views
You have to use ShellExecuteEx instead; type (T_)SHELLEXECUTEINFO contains hProcess member which you can WaitForSingleObject on.
0 Kudos
Steven_L_Intel1
Employee
1,756 Views
I see I have to fix the HTML in that article so that the callout numbers are shown. I think I know what happened here...

I recommend reading back issues of the newsletter to all - many questions asked in this forum are answered in various articles.

Steve
0 Kudos
rahzan
New Contributor I
1,756 Views
Thanks Jugoslav,
I had originally looked at the Ex version and the were so many settings I thought I'd be experimenting for ever. I'll give it another try.


Steve,
I used to get notices whenever these newletters came out but no more. How can I sign up for them?

Tim
0 Kudos
rahzan
New Contributor I
1,756 Views
And one other thing:
I declared lpParam as a character(80) so that it can be assign under different conditions. But the line
lpParam=NULL_CHARCATER
produced an " access violation".
setting it char(0) seems to go ok.

any ideas?

Tim
0 Kudos
Steven_L_Intel1
Employee
1,756 Views
Tim,

We haven't issued a newsletter in a long time, but hope to get a new one out soon. If you got the notice about Intel Fortran 7, you're on the list.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,756 Views
Re lpParameters: My reading of the docs is that

- if lpFile is an .exe file, lpParameters mustn't be NULL
- if lpFile is a document, lpParameters should be NULL.

Jugoslav
0 Kudos
rahzan
New Contributor I
1,756 Views
The reason I used ShellExec. was that I wanted to open and MDB file(ms-access),
otherwise RunQQ would do fine for an .EXE.

So lpFile is a document, yet NULL gives the axs viol. this contardicts your guess, jugoslav, right?

Anyway, is there a difference between NULL_CHARACTER and char(0)??

Tim
0 Kudos
Steven_L_Intel1
Employee
1,756 Views
NULL_CHARACTER passes the address zero. CHAR(0) passes the address of a zero-length string (in C terms). The lpFile parameter is not documented as permitting a NULL address, so pass CHAR(0) if you want to omit it.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,756 Views
No, my interp of lpParameters was correct; however, I didn't look carefully at Tim's code. He was trying to

CHARACTER(80) lpParam
...
lpParam = NULL_CHARACTER !Access violation

you mustn't copy from address of 0 anywhere.

- NULL_CHARACTER is of type character and has address 0
- char(0) is of type character and has a valid address, containing binary zero.
- NULL is the same as 0 in Fortran

Note that SHELLEXECUTEINFO%lpParameters is declared as an INTEGER(LPCTSTR); however, in INTERFACE to ShellExecute, lpParameters is declared as CHARACTER(*). Thus, in the former, assign NULL (or 0) to that SEI%lpParameters. In the latter, use NULL_CHARACTER:

SEI%cbSize = SIZEOF(SEI)
SEI%fMask = SEE_MASK_NOCLOSEPROCESS
SEI%hwnd = NULL
SEI%lpVerb = LOC("open"C)
SEI%lpFile = "C:mydatamybase.mdb"C
SEI%lpParameters = NULL
SEI%lpDirectory = NULL
SEI%nShow = SW_SHOWDEFAULT
!Other members are either Output or unused, depending on fMask.

Jugoslav

0 Kudos
Reply