IonicWind Software

IWBasic => General Questions => Topic started by: ckoehn on January 16, 2010, 04:51:45 PM

Title: GetVolumeInformation
Post by: ckoehn on January 16, 2010, 04:51:45 PM
Here is a Win32 API call.  How do you format it to work in EBASIC?

BOOLEAN GetVolumeInformation(LPCTSTR lpRootPathName,LPTSTR lpVolumeNameBuffer,DWORD nVolumeNameSize,LPDWORD lpVolumeSerialNumber,LPDWORD lpMaximumComponentLength,LPDWORD lpFileSystemFlags,LPTSTR lpFileSystemNameBuffer,DWORD nFileSystemNameSize)

Thanks,
Clint
Title: Re: GetVolumeInformation
Post by: LarryMc on January 16, 2010, 05:29:01 PM
DECLARE "kernel32.dll" Alias "GetVolumeInformationA",GetVolumeInformation(lpRootPathName:STRING, lpVolumeNameBuffer:STRING, nVolumeNameSize:INT, lpVolumeSerialNumber:INT, lpMaximumComponentLength:INT, lpFileSystemFlags:INT, lpFileSystemNameBuffer:STRING, nFileSystemNameSize:INT),INT

Larry
Title: Re: GetVolumeInformation
Post by: ckoehn on January 16, 2010, 05:37:57 PM
Thanks Larry.  Will try it.
Title: Re: GetVolumeInformation
Post by: ckoehn on January 16, 2010, 05:45:19 PM
I tried it and received a syntax error.  It was like a comma was generating the error.  It looked OK to me.  What is it?
Title: Re: GetVolumeInformation
Post by: ckoehn on January 16, 2010, 05:53:29 PM
I'm wanting to retrieve the serial number off of a harddrive.  It doesn't seem to be working.  It looks like you need pointers and I'm not sure how to do that.

Thanks
Title: Re: GetVolumeInformation
Post by: LarryMc on January 16, 2010, 05:58:34 PM
Quote from: ckoehn on January 16, 2010, 05:45:19 PM
I tried it and received a syntax error.  It was like a comma was generating the error.  It looked OK to me.  What is it?
Post some code so we can see the error.

Larry
Title: Re: GetVolumeInformation
Post by: ckoehn on January 16, 2010, 06:06:31 PM
DECLARE "kernel32.dll" Alias "GetVolumeInformationA",GetVolumeInformation(lpRootPathName:STRING, lpVolumeNameBuffer:STRING, nVolumeNameSize:INT, lpVolumeSerialNumber:INT, lpMaximumComponentLength:INT, lpFileSystemFlags:INT, lpFileSystemNameBuffer:STRING, nFileSystemNameSize:INT),INT'

Compiling...
Test.eba
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\SongIndex2009.eba (32) syntax error - Alias
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\SongIndex2009.eba (32) syntax error - ,
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\SongIndex2009.eba (32) syntax error - ,
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\SongIndex2009.eba (32) syntax error - ,
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\SongIndex2009.eba (32) syntax error - ,
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\SongIndex2009.eba (32) syntax error - ,
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\SongIndex2009.eba (32) syntax error - ,
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\SongIndex2009.eba (32) syntax error - ,
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\SongIndex2009.eba (32) syntax error - )

Error(s) in compiling "C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\Test.eba"
Title: Re: GetVolumeInformation
Post by: LarryMc on January 16, 2010, 06:15:13 PM
Sorry, my bad.  I used an old declaration.

Try this:
DECLARE IMPORT,  GetVolumeInformationA Alias GetVolumeInformation(lpRootPathName:STRING, lpVolumeNameBuffer:STRING, nVolumeNameSize:INT, lpVolumeSerialNumber:INT, lpMaximumComponentLength:INT, lpFileSystemFlags:INT, lpFileSystemNameBuffer:STRING, nFileSystemNameSize:INT),INT'

Larry
Title: Re: GetVolumeInformation
Post by: ckoehn on January 16, 2010, 06:29:46 PM
Here is my program.  It still doesn't work.


DECLARE IMPORT,  GetVolumeInformationA Alias GetVolumeInformation(lpRootPathName:STRING, lpVolumeNameBuffer:STRING, nVolumeNameSize:INT, lpVolumeSerialNumber:INT, lpMaximumComponentLength:INT, lpFileSystemFlags:INT, lpFileSystemNameBuffer:STRING, nFileSystemNameSize:INT),INT

DEF win:WINDOW
DEF VolName,FileSysName:STRING
DEF ret,SerialNumber:INT

OPENWINDOW win,0,0,600,350,@SIZE|@MINBOX|@MAXBOX,0,"Test",&mainwindow

ret=GetVolumeInformation("C",VolName,254,SerialNumber,0,0,FileSysName,254)

MOVE win,10,10
PRINT win,"Serial Number: "+Str$(SerialNumber)

run=1

WAITUNTIL run=0

CLOSEWINDOW win
END

SUB mainwindow
SELECT @CLASS
CASE @IDCLOSEWINDOW
run=0
CASE @IDCREATE
CENTERWINDOW win
ENDSELECT
ENDSUB


Here is the errors.

Compiling...
Test.eba
File: C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\Test.eba (9) Warning: undeclared function 'GetVolumeInformation'
C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\Test.a:89: error: symbol `GetVolumeInformation' undefined
C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\Test.a:232: error: phase error detected at end of assembly.
Error(s) in assembling "C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\Test.a"
Title: Re: GetVolumeInformation
Post by: LarryMc on January 16, 2010, 07:06:01 PM
try the correct function name ;)

ret=GetVolumeInformationA("C",VolName,254,SerialNumber,0,0,FileSysName,254)

Larry
Title: Re: GetVolumeInformation
Post by: ckoehn on January 16, 2010, 07:23:51 PM
I did and this is what I received.


DECLARE IMPORT,  GetVolumeInformationA Alias GetVolumeInformation(lpRootPathName:STRING, lpVolumeNameBuffer:STRING, nVolumeNameSize:INT, lpVolumeSerialNumber:INT, lpMaximumComponentLength:INT, lpFileSystemFlags:INT, lpFileSystemNameBuffer:STRING, nFileSystemNameSize:INT),INT

DEF win:WINDOW
DEF VolName,FileSysName:STRING
DEF ret,SerialNumber:INT

OPENWINDOW win,0,0,600,350,@SIZE|@MINBOX|@MAXBOX,0,"Test",&mainwindow

ret=GetVolumeInformationA("C",VolName,254,SerialNumber,0,0,FileSysName,254)

MOVE win,10,10
PRINT win,"Serial Number: "+Str$(SerialNumber)

run=1

WAITUNTIL run=0

CLOSEWINDOW win
END

SUB mainwindow
SELECT @CLASS
CASE @IDCLOSEWINDOW
run=0
CASE @IDCREATE
CENTERWINDOW win
ENDSELECT
ENDSUB


Compiling...
Test.eba
No Errors

Linking...
Emergence Linker v1.12 Copyright ÂÃ,© 2009 Ionic Wind Software
Unresolved external __imp_GetVolumeInformation
Error: Unresolved extern __imp_GetVolumeInformation
Error(s) in linking C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\Test.exe
Title: Re: GetVolumeInformation
Post by: LarryMc on January 16, 2010, 07:41:39 PM
Okay, let's try this.

Forget the declare - comment it out

change the function name to this _GetVolumeInformation

Larry
Title: Re: GetVolumeInformation
Post by: LarryMc on January 16, 2010, 07:46:07 PM
If that doesn't work then use the "find in files" option of the tools menu and search for GetVolumeInformation in the EBDEV\includes directory.

if you find it then use $include "whatever.inc" at the beginning of your program.

Larry

NOTE: the reason I have so much trouble is that I've got a ton of extra add-on libs and incs on my computer.
Title: Re: GetVolumeInformation
Post by: LarryMc on January 16, 2010, 07:52:55 PM
This works on my computer ( thanks to Allden - 2003):
DECLARE "Kernel32.dll",GetVolumeInformationA(lpRootName:STRING,lpVolumeName:STRING,nVolumeLen:INT,lpSerial:POINTER,lpMaxComponentLength:POINTER,lpFileSystemFlags:POINTER,lpFileSystemName:STRING,nFileSystemNameLen:INT),INT
' Declare the call
Def name:string :'Buffer for lpRootName
Def filesystemname:string :'This will be used to return the file system name (FAT FAT32 NTFS)
Def DrivePath:string :' This string holds what path we will use in the call
Def flags,serialnumber,maxcomponentlength:int: ' Integers of the call
flags=0:serialnumber=0:maxcomponentlength=0 :' Make sure there all set to zero
DrivePath="C:\\" :'DrivePath
GetVolumeInformationA(Drivepath,name,255,serialnumber,maxcomponentlength,flags,filesystemname,255)
' Call the function
openconsole
if name<>"" then print "Drive Name=",name :' If a name is present , print that name
print "Serial number=",serialnumber," File system=",filesystemname :' Serial number & file system name (FAT FAT32 NTFS)
print "Press any key to continue....." :'Exit code
do : until inkey$<>""
closeconsole : end
Title: Re: GetVolumeInformation
Post by: ckoehn on January 16, 2010, 08:15:11 PM
Thanks Larry.  Works great.