Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP9 test EXE doesn't respect parameters :-(
Message
De
18/06/2014 09:35:13
 
 
À
22/12/2013 18:45:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01590839
Message ID:
01602033
Vues:
70
Hi:

It have been a while from this post, and I've found a solution which I post here just in case somebody is interested or need it.

I actually found 2 solutions: One in VFP and one using VB script.


In VFP I use this code to get the parameters from DOS and bypass what Fox can "see":
LPARAMETERS P01, P02, P03, P04, P05, P06, P07, P08, P09, P10

#DEFINE CR_LF	CHR(13) + CHR(10)
LOCAL lsBuffer, lnAddress, lnBufsize, lnPcount
lnPcount	= PCOUNT()

IF lnPcount <= 1	&& Fox can't see them... but they are there :)
   * GET THE ENTIRE COMMAND LINE
   * Code adapted from http://www.news2news.com/vfp/?example=51&function=78
   * Given by Mario Lopez on Spanish FoxPro Google Group - 23/12/2013
   * https://groups.google.com/d/msg/publicesvfoxpro/llS-kTNrG9M/LA4D3fd152IJ
   *-----------------------------------------------------------------------------
   DECLARE INTEGER GetCommandLine IN kernel32
   DECLARE INTEGER GlobalSize IN kernel32 INTEGER HMEM
   DECLARE RtlMoveMemory IN kernel32 AS CopyMemory STRING @Destination, INTEGER SOURCE, INTEGER nLength

   lnAddress = GetCommandLine()  && returns an address in memory
   lnBufsize = GlobalSize(lnAddress)

   * allocating and filling a buffer
   IF lnBufsize <> 0
      lsBuffer = REPLICATE(CHR(0), lnBufsize)
      = CopyMemory(@lsBuffer, lnAddress, lnBufsize)
   ENDIF

   lsBuffer = CHRTRAN(lsBuffer, CHR(0)+'"', " ")

   FOR I = 1 TO OCCURS("'", lsBuffer) / 2
      STORE STREXTRACT(lsBuffer, "'", "'", I*2-1, 0) TO ('P' + TRANSFORM(I,'@L ##'))
      lnPcount = lnPcount + 1
   ENDFOR

   RELEASE lsBuffer, lnAddress, lnBufsize
   CLEAR DLLS 'GetCommandLine', 'GlobalSize', 'RtlMoveMemory'
ENDIF
.


In VBScript is easier, I just use this (just the important parts):
Set WSHShell = WScript.CreateObject("WScript.Shell")
For I = 1 TO WScript.Arguments.Count
   cParam = WScript.Arguments(x)
Next
.


Thanks all for the answers.

Best regards!
Fernando D. Bozzo
Madrid / Spain
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform