Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetWindowsDirectory
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00291459
Message ID:
00291663
Vues:
28
The C Function:
UINT GetWindowsDirectory(
  LPTSTR lpBuffer,  // buffer for Windows directory
  UINT uSize        // size of directory buffer
);
Is declared in VFP like this:
DECLARE Integer GetWindowsDirectory IN win32api AS GetWindowsDirectory ;
  string @ cBuffer, ;
  Integer nSize
using Integer for UINT, and a character variable *by reference* where the API wants a pointer to a buffer. The variable names in the declaration are optional, and don't need to be the same as the ones you actually use.

First you set up a buffer big enough to hold the value
cWinDir = space(255)
nSize = len(cWinDir)
Then call the function. Note the @, which passes cWinDir by reference
nPathLength = GetWindowsDirectory(@cWinDir, nSize)
GetWindowsDirectory returns the lengh of the string it put in the buffer, so use it to trim off the extra characters padding out your variable
cWinDir = left(cWinDir, nPathLength)
Hope that helps.

>There is little I can find on this WIN32API function as it pertains to anything other than C++. Any thoughts as to its arguments or an alternative means to achieving the same result? The aim is to get the "windows" directory.Thank you in advance.
Peter Franz
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform