ShellExecute

Hello:

I am doing programming work in Visual FoxPro (VFP), and I have been at it for so long that my brain is closing down :slight_smile:

You are probably familiar with ShellExecute, which I am using to try to open a folder in Dopus (rather than in the default Windows Explorer). Here is the ShellExecute stuff:

DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin

Here is what I have in a VFP button

cFileName = "C:\Program Files\GPSoftware\Directory Opus\dopus.exe"
cAction = "open"
cParams = "D:\VFP Applications"
ShellExecute(0,cAction,cFileName,cParams,"",1)

When I click the button, DOpus indeed opens, but it opens folder "D:\VFP" (which does not exist, so it is empty), not the intended "D:\VFP Applications".

Would anyone know what I need to do to get it to open the correct folder? Maybe Dopus requires something else as parameters when opening a particular folder.

By the way, this works in Windows Command Prompt:

"C:\Program Files\GPSoftware\Directory Opus\dopus.exe" "D:\VFP Applications"

but in ShellExecut, these two commands do not work:

cFileName = "C:\Program Files\GPSoftware\Directory Opus\dopus.exe" "D:\VFP Applications"

cFileName = "C:\Program Files\GPSoftware\Directory Opus\dopus.exe D:\VFP Applications"

Grateful for some tips.

Hans L

Try DOpusRT.

The cParams string probably needs to have quotes inside the string around the path. (I don't know how you do that in Visual FoxPro.)

Leo, I tried " 'D:\VFP applications' " . Unfortunately, it did not work.

Let me ask you to confirm that the correct way to open a folder in Dopus is this:

C:\Program Files\GPSoftware\Directory Opus\dopus.exe /D:\VFP Applications

Regards,

Hans L

If it's opening D:\VFP then the problem is going to be quoting. But you will have to work out how to quote the path in the language you're using, since it's not one I know anything about.

Try running the command from a Command Prompt first, to see if you have the right command line. Once you have that working (which we can help with if needed, but I think it's just what's below), then worry about how to generate that command line in the programming language you are using. Trying to solve both at once will just confuse you.

"C:\Program Files\GPSoftware\Directory Opus\dopus.exe" "D:\VFP Applications"

If you have the correct command line working via a Command Prompt, then your question is no longer about Opus (since the Opus side of things is known and solved) and only about how to run and/or quote commands in Visual FoxPro; if you're at that point then asking on a forum with people who use Visual FoxPro would make the most sense, as they'll know how to do it.

I tried this earlier:

"C:\Program Files\GPSoftware\Directory Opus\dopus.exe" "D:\VFP Applications"

It worked then, it works now.

The ShellExecute script does not like spaces in folder names (and I do not believe this is only in VFP). But when I now run a code that an experienced VFP programmer gave me, I wind up here:

C:\Windows\System32[D:\VFP

(non-existant folder, of course). The ShellExecute code in VFP was this:

cFileName = "C:\Program Files\GPSoftware\Directory Opus\dopus.exe "
cAction = "open"
ShellExecute(0,cAction,cFileName,"[D:\VFP applications]","",1)

Ah, I read a short description in VFP of the use of square brackets, and the VFP programmer madea mistake (he knows, so it was an 'honest' mistake). The code should be this:

ShellExecute(0,cAction,cFileName,["D:\VFP applications"],"",1)

that is, the quotation marks should be inside the square brackets.

Finally, after a full day, and hundreds of tries, it works! Phu..Thanks for your interest in this. It helped me!

Hans L

I just tried the six version below, which, according to Visual FoxPro, should work similarly (the ShellExecutive code is shown first):

cFileName = β€œC:\Program Files\GPSoftware\Directory Opus\dopus.exe β€œ
cAction = β€œopen"
ShellExecute(0,cAction,cFileName,”[D:\VFP applications]”,”",1)

but, as you can see, only two of the six worked.

["D:\VFP Applications"] WORKED
'"D:\VFP Applications"' WORKED (single quote outside the double quotes)

"[D:\VFP Applications]" C:\Windows\system32[D:\VFP
"'D:\VFP Applications'" C:\Windows\system32[D:\VFP (double quotes outside the single quotes)
['D:\VFP Applications'] C:\Windows\system32[D:\VFP
'[D:\VFP Applications' C:\Windows\system32[D:\VFP

I can only assume that Dopus requires a double quote around it to open.

Regards,

Hans L