Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Trying to call kernel32.dll GetVolumeInformationA and return a value...

Author
Message
feiting shadow
12
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 11th Mar 2009 09:34
Ok so I need help. If this was any other Basic language, I would have (and have) figured this out, but DB's way of calling DLL's differs a bit.

I've gone through the API docs on andreasvb and made sure the parameters matched, even explicitly said variable$ as string and such, but no matter what I type, I always get 0 as the volume serial and/or name. I'll post my code, as that should show what I'm doing wrong.

If I could just have one example of how to call this thing to return a value, it would be much appreciated. Also, previous threads with kernel32 or DLL's, I did search, and only found ones that don't have more than one parameter being returned. I'll work on this more tomorrow morning, been up for 19 hours so far.

Thanks.

ps. that's just the relevant snippet, I copied from the tutorial then modified it using the API how-to websites.

Signed
------
Benjamin
16
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Mar 2009 12:26 Edited at: 11th Mar 2009 12:27
It would help to see the entire thing. It's impossible to see if any variables are initialized (correctly) here.

IanM
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Mar 2009 15:17
Quote: "DB's way of calling DLL's differs a bit."

Actually, it's quite similar to VB6.

The mistake you are making is that the string variables are used for output, and so have to be presized to allow the data to safely be written.

I'll post an example using that API tonight - I'll expand the code I already have to include all the retrievable values where possible.

IanM
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Mar 2009 21:44


feiting shadow
12
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 11th Mar 2009 23:02 Edited at: 12th Mar 2009 08:06
ah thanks Ian! I had no idea they needed to be presized. Also that's quite an example.

lol @ Benjamin. The last uncommented lines to that are endif and end.

I just woke up, man 13 hours of sleep... makes up for the 4.5 yesterday. I'll rewrite my app and see if I can get it working. Thanks!

EDIT: Ok so I just copied what you had after being awake enough to read it, and it works! Thank you! I'm going to use that call for writing my own antipiracy algorithm, as it doesn't need to be powerful, just something that'll "Keep the honest ones honest.", once I polish my Kana program enough.

Alright, now to see who I can lend a hand to in the newbie forums

Signed
------
feiting shadow
12
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 13th Mar 2009 11:57
Made it easy, check out this PB source for usage example, but the download is now a DLL that simply returns a string.



Thanks for the help guys!

Signed
------

Attachments

Login to view attachments

Login to post a reply

Server time is: 2019-04-21 18:19:48
Your offset time is: 2019-04-21 18:19:48