Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running VFP module from FoxPro 2.6 using run command
Message
From
05/10/1997 22:20:20
 
 
To
25/09/1997 11:43:58
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00051338
Message ID:
00053359
Views:
42
>>Any time that I've wanted to do
>this from FPW2.6, I've resorted to
>>calling WinExec(). In addition to
>having better control over the
>>appearance of the application being run,
>you get some feedback on the
>>results (eg. if it ran at all). I've also
>found it easier to control
>>the passing of parameters to the new
>applications.
>
>Thanks a lot for your feedback. Do you know from
>the top of your head a syntax
>of using WinExec command in my scenario? I
>think a have to register this function
>using FoxTools? What I need is to
>run some EXE with couple parameters.

There are two steps: 1) setup the call to WinExec() and 2) execute the
call. The code that I use for both is included here.
*****
* Load the FoxTools Library if necessary
*****
if _WINDOWS and not "FOXTOOLS" $ set('LIBRARY')
  set library to ("foxtools") additive
endif

*****
* Define the Library functions if this is in Windows
*****
if _WINDOWS

  public snWNetGetUser
  m.snWNetGetUser = RegFn("WNetGetUser","@C@I","I")

  public snGetProfile, snWriteProfile
  m.snGetProfile = RegFn("GetProfileString","CCC@CI","I")
  m.snWriteProfile = RegFn("WriteProfileString","CCC","I")

  public snPostMessage
  m.snPostMessage = RegFn("PostMessage","IICC","I")

  public snWinExec
  m.snWinExec = RegFn("WinExec","CI","I")

endif


    *****
    * PAR 12-Mar-97 - If a file exists called WINEXEC.FIL, then the
WinExec
    *                 function will be used.  Otherwise, the regular RUN
    *                 function will be used.
    *****
    m.lnWinExec = 1000
    if file("WINEXEC.FIL")
      m.lnWinExec = &CallFn(m.snWinExec,"PRINTFIL.BAT "+m.lpFile,2)
    else
      run printfil.bat &lpFile
    endif

  *  erase &lpFile
    if not m.slDebug
      erase &lpFile1
      erase &lpFile2
    endif

    *****
    * PAR 26-Sep-96 - Setup the application to save additional error
information
    *****
    if m.lnWinExec < 32
      *****
      * Setup the Error information
      *****
      m.lcWinExec = "Unknown Error"
      do case
        case m.lnWinExec = 0
          m.lcWinExec = "Out of memory or Corrupt File"
        case m.lnWinExec = 2
          m.lcWinExec = "File Not Found"
        case m.lnWinExec = 3
          m.lcWinExec = "Path Not Found"
        case m.lnWinExec = 5
          m.lcWinExec = "Dynamic Link Error or Sharing Error"
        case m.lnWinExec = 6
          m.lcWinExec = "Separate Data Segments Required"
        case m.lnWinExec = 8
          m.lcWinExec = "Insufficient Memory"
        case m.lnWinExec = 10
          m.lcWinExec = "Incorrect Windows Version"
        case m.lnWinExec = 11
          m.lcWinExec = "Invalid Executable File"
        case m.lnWinExec = 12
          m.lcWinExec = "Incorrect Operating System"
        case m.lnWinExec = 13
          m.lcWinExec = "Designed for MS-DOS 4.0"
        case m.lnWinExec = 14
          m.lcWinExec = "Unknown Executable File Type"
        case m.lnWinExec = 15
          m.lcWinExec = "Real-Mode Application"
        case m.lnWinExec = 16
          m.lcWinExec = "Attempted to load Second Instance"
        case m.lnWinExec = 19
          m.lcWinExec = "Attempted to load Compressed EXE"
        case m.lnWinExec = 20
          m.lcWinExec = "Invalid DLL"
        case m.lnWinExec = 21
          m.lcWinExec = "32-bit extensions required"
      endcase
      *****
      * Generate an error.
      * This will call the regular error handler.
      *****
      m.lnRoot = sqrt(-1)
    endif
Paul Russell
EMail: prussell@fox.nstn.ca
Phone: (902) 499-5043
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform