Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FindWindow
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00172288
Message ID:
00172472
Views:
40
>>>Thanks, it works. However, is there some book,document or whatever that explains all this. I mean, it looks like you are declaring a function that is going to receive 2 string parameters and then it is called with 1 numeric and 1 string. This is not intuitively obvious. In Delphi, I call the same function with 2 pChar parameters. I didn't think C was this forgiving. Again, Thanks :)
>>
>>Hi Calvin,
>>
>>PMFJI, but there are a couple of things I want to touch on. First, the declaration should (according to the SDK) pass the strings by reference not value. However, in many cases I've found it doesn't matter. However, because it sometimes does, I try to stick to the method shown in the SDK all the time. Now when you pass a 0 when passing by reference, you're actually passing a null pointer. I think what happens here is that it's assumed to be a null string by VFP, but this is a guess.
>>
>
>George,
>
>All STRING declarations are ByRefs; what is passed to the API call is the same regardless of whether your DECLARE...DLL has a STRING cSomeValue or a STRING @ cSomeValue. I don't know why this occurs, and it doesn't make sense, but it does appear to be the behavior.
>
Hi Ed,

Well, I wouldn't make that assumption. Try the following:
DECLARE SHORT GetVolumeInformation IN Win32api;
  STRING @lpRootPathName, STRING lpVolumeNameBuffer,;
  INTEGER nVolumeNameSize, INTEGER @lpVolumeSerialNumber,;
  INTEGER @lpMaximumComponentLength, INTEGER @lpFileSystemFlags,;
  STRING @lpFileSystemNameBuffer, INTEGER nFileSystemNameSize
lnbuflen = 260
STORE SPACE(lnbuflen) TO lcvolname, lcsysname
STORE 0 TO STORE 0 TO lncomp, lnfilesys, lnserial
lcroot = 'C:\'
llresult = (GetVolumeInformation(@lcroot, lcvolname, lnbuflen,;
  @lnserial, @lncomp, @lnfilesys, @lcsysname, lnbuflen) # 0) && returns .T.
? EMPTY(lcvolname) && Returns .T.
STORE SPACE(lnbuflen) TO lcvolname, lcsysname
STORE 0 TO STORE 0 TO lncomp, lnfilesys, lnserial
DECLARE SHORT GetVolumeInformation IN Win32api;
  STRING @lpRootPathName, STRING @lpVolumeNameBuffer,;
  INTEGER nVolumeNameSize, INTEGER @lpVolumeSerialNumber,;
  INTEGER @lpMaximumComponentLength, INTEGER @lpFileSystemFlags,;
  STRING @lpFileSystemNameBuffer, INTEGER nFileSystemNameSize
llresult = (GetVolumeInformation(@lcroot, @lcvolname, lnbuflen,;
  @lnserial, @lncomp, @lnfilesys, @lcsysname, lnbuflen) # 0) && returns .T.
? EMPTY(lcvolname) && Returns .F.
What I did note was that if I didn't declare it as being passed by reference, but passed it as such, it did work. However, this is one of those cases where you have to explicitly pass the string by reference.
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform