DECLS convertion ?
BlitzMax Forums/BlitzMax Programming/DECLS convertion ?
| ||
Hi :) How i can convert this B3D DECLS entry => BMax ? .lib "Kernel32.dll" GetDriveType%(drivename$):"GetDriveTypeA" GetVolumeInformation%(Path$,VolNameBuff*,VolLen%,Serial*,MaxComponentLen*,fsFlags*,fsNameBuff*,fsNameLen%):"GetVolumeInformationA" GetLogicalDriveStrings%(bufflen%,buffer*):"GetLogicalDriveStringsA" GetLogicalDrives%() Cheers |
| ||
Try:?Win32 Extern "Win32" Function GetDriveType:Int(DriveName:Byte Ptr)="GetDriveTypeA" End Extern ? And so on and so forth. |
| ||
$z surely? |
| ||
Thanks noel ! but i have a question ? how call this ? i have try GetDriveType("D:") But the compiler say : C:/BMax/sources/IGlass test/IGlass 1.5/.bmx/Example FileSelector.bmx.o(code+0x358): undefined reference to `GetDriveType@4' |
| ||
Print GetDriveType("D:\") Extern "Win32" Function GetDriveType:Int(DrivePath$z) = "GetDriveTypeA@4" End Extern |
| ||
Many many thanks !!! A last question :) why make : DrivePath$z Why the $z ??? |
| ||
$z is a C-Style null-terminated string. So if you have a normal blitz string (instead of a string literal), you will probably need to use ToCString to convert it. *EDIT* apparently not. It seems to work with a normal Blitz String. |
| ||
For future reference, point your command prompt to Bmax/lib and type: nm [filename] >[filename].txt to get a listing of the functions available for that lib. i.e. nm libwinmm.a >winmm.txt |
| ||
Thanks ! it work ! |
| ||
Forgive the stupid question(s), but: - What is ?Win32 ... ? Is this a shortcut command of some kind? (I'm not up on all the lingo yet..) - What does the '@4' at the end of 'GetDriveTypeA' mean? Thanks, Russell |
| ||
What is ?Win32 ... ? Is this a shortcut command of some kind? (I'm not up on all the lingo yet..) From what I can tell (and I may be wrong), it is a directive telling the compiler that you are calling a win32 library. It will still compile and run if you remove it, but you get an error when your program exits. What does the '@4' at the end of 'GetDriveTypeA' mean? It means the return value is 4 bytes in size. In other words a 32bit integer value. |
| ||
Perturbatio (Posted 2005-02-24 02:05:19) What is ?Win32 ... ? Is this a shortcut command of some kind? (I'm not up on all the lingo yet..) From what I can tell (and I may be wrong), it is a directive telling the compiler that you are calling a win32 library. It will still compile and run if you remove it, but you get an error when your program exits. The ?Win32...? just tells BMax to compile that bit only on a Windows system (compiler directive). The bit that's telling BMax that you are calling a Windows library would be...Extern "Win32" That's the way I understand it at least. I too could be wrong though ;o) |
| ||
oops, stupid me, I was assuming he was referring to the win32 part in the extern command. I never even paid attention to the question marks. |
| ||
Well that's good to know that OS-specific compiler directives are available (as long as they're used with care to maintain portability...) Thanks for the answers. I learn a little bit more each day... Russell |
| ||
Actually, the @4 is the size of the stack for all the pushed parameters, when calling the function. |