May 09, 2024, 11:52:05 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


GetVolumeInformation

Started by ckoehn, January 16, 2010, 04:51:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ckoehn

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

LarryMc

DECLARE "kernel32.dll" Alias "GetVolumeInformationA",GetVolumeInformation(lpRootPathName:STRING, lpVolumeNameBuffer:STRING, nVolumeNameSize:INT, lpVolumeSerialNumber:INT, lpMaximumComponentLength:INT, lpFileSystemFlags:INT, lpFileSystemNameBuffer:STRING, nFileSystemNameSize:INT),INT

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn


ckoehn

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?

ckoehn

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

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

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"

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

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"

LarryMc

try the correct function name ;)

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

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

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

LarryMc

Okay, let's try this.

Forget the declare - comment it out

change the function name to this _GetVolumeInformation

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

January 16, 2010, 07:46:07 PM #12 Last Edit: January 16, 2010, 07:47:51 PM by Larry McCaughn
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.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

Thanks Larry.  Works great.