Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Who has the file opened in NT 4.0
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00161537
Message ID:
00162464
Vues:
27
>Thank you for the info Ed,
>
>I've managed to get the NetFileEnum function to return values, however, I have no experience with manipulating the bufptrs.
>
>Can you guide me to some examples for extracting these pointer values?

Unfortunately, not as much help as you'll porbably need; hopefully, you can use either paul Tatavu's POINTERS class to help move the string values you need into VFP variables, or you can follow up on what george Tasker has been doing with RtlMoveMemory() to copy the data back into VFP variables for you.

If you're getting back level 3 structures from NetFileEnum(), the return buffer contains a FILE_INFO_3 structure. A FILE_INFO_3 structure is:
typedef struct _FILE_INFO_3 {
    DWORD     fi3_id;
    DWORD     fi3_permissions;
    DWORD     fi3_num_locks;
    LPTSTR    fi3_pathname;
    LPTSTR    fi3_username;
} FILE_INFO_3, *PFILE_INFO_3, *LPFILE_INFO_3;
Each FILE_INFO_3 structure is 20 bytes long; there are 5 4-byte long values, the first three are DWORDs (unsigned 32 bit integers), a file id, the permission mask for the file, and the number of locks held on the file. These are simple to decode into VFP integers:

FUNCTION ExtractDWORD
LPARAMETER cStringToExtractFrom
IF TYPE('cStringToExtractFrom')='C' AND LEN(cStringToExtractFrom) >= 4
RETURN (((ASC(SUBST(cStringToExtractFrom,4,1))*256) + ;
ASC(SUBST(cStringToExtractFrom,3,1)))*256 + ;
ASC(SUBST(cStringToExtractFrom,2,1)))*256 + ;
ASC(LEFT(cStringToExtractFrom,1))
ELSE
this.icErrorMessage = 'Invalid DWORD string passed for conversion'
RETURN NULL
ENDIF


The last two are actually pointers to memory; these point to null-terminated strings that lie outside the variable address space for VFP. You need to use an API call like lstrcopy() or RtlMoveMemory() to move the strings from these memory addresses into memory that is allocated to VFP string variables. george Tasker has been playing with using RtlMoveMemory() recently, and might have code that would do this for you; since these are null-terminated strings, you could also use lstrcopy() which is designed to copy CStrings from one memory location to another.

Another approach would be to use Paul Tatavu's POINTERS class; Paul has created an OCX that has some native methods to copy to and from VFP strings. it's pretty easy to use, and is not terribly expensive. You can download a demo (nagware) version here on UT.

Pat Boens' .FLLs may also have the necessary functions to handle the memory moves for you. He may even have an FLL wrapper for NetFileEnum() in there somewhere!


What I've done myself is to write some C wrappers that my VFP code talks to using straight parameter passing; the C code does the job of moving things from the buffers into VFP memory variables. Unfortunately, that code is owned by my employer, so I can't really post it here on UT; you have the base logic behind what the wrapper .DLL does in this and my previosu message describing the API call.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform