Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to send a file to cd driver, like "Send to" in Win Xp? 2

Status
Not open for further replies.

knela

Programmer
Jan 26, 2007
13
BR
Hello! I would like to creat a function in my program, to send a file/directory to cd drive, like the function "Send to" on Windows Xp. I'm using VP9.
 
Code:
LOCAL lnDriveMap, lnDrive, lcDrive

DECLARE INTEGER GetLogicalDrives IN kernel32 

lnDriveMap = GetLogicalDrives()

FOR lnDrive = 0 TO 25
	lcDrive = Chr(lnDrive + 65)
	IF DriveType(lcDrive) = 5
		*--This is a CD. Do whatever.
		EXIT 
	ENDIF 
ENDFOR

pamela
 
Hi Pamela,

Just looking at the code you posted, where do you use the API? To get the number of logical drives? But you're not using this number in the code bellow.
 
Or you can call FoxTools for VFP6 & below or VFP7 & above use the VFP commands

*/***************************************************************************
*# Disk Type
*/Program : Disk_Type
*/System : Fox Library
*/Purpose : Returns a number indicating the type of the drive.
*/Syntax : integer = Disk_Type(path,WinApi)
*/Parameter : Path - String - Must include drive letter
*/ : WinApi - Logical - If you want to use Windows instead of FoxTools.fll
*/Returns : Number indicating the DriveType
*/Defaults : Current Default drive
*/Requires : Path set to FoxTools.fll
*/Changes : nothing
*/Calls : Foxtools.fll / Windows API routines
*/Version :
*/Dated : David Grewe
*/Written By: 10 July 1995
*/***************************************************************************
*& Utility - Disk Drive Handling
*/***************************************************************************
*/ Record Of Change
*/
*/***************************************************************************
*-------------------------------------------------------
* 0 : DRIVE_UNKNOWN : The drive type cannot be determined.
* 1 : DRIVE_NO_ROOT_DIR : The root path is invalid. For example, no volume is mounted at the path.
* 2 : DRIVE_REMOVABLE : The disk can be removed from the drive.
* 3 : DRIVE_FIXED : The disk cannot be removed from the drive.
* 4 : DRIVE_REMOTE : The drive is a remote (network) drive.
* 5 : DRIVE_CDROM : The drive is a CD-ROM drive.
* 6 : DRIVE_RAMDISK : The drive is a RAM disk.
*-------------------------------------------------------
FUNCTION Disk_Type as Number
LPARAMETERS pcRootPath,plWinApi
IF PARAMETERS() < 1 OR vartype(pcRootPath)<>"C" OR EMPTY(pcRootPath)
pcRootPath = SYS(5)
ENDIF
*
LOCAL lnReturn as Integer
*
IF plWinApi
declare long GetDriveTypeA in "KERNEL32" as "APIGetDriveType" string nDrive
lnReturn = APIGetDriveType(pcRootPath)
ELSE
lnReturn = DriveType(pcRootPath)
ENDIF

RELEASE pcRootPath,plWinApi
RETURN lnReturn
ENDFUNC


David W. Grewe Dave
 
Pamala,

I don't understand the code you posted.

You are calling GetLogicalDrives(), which I understand returns a bitmap of the logical drives, but you are not using the value that it returns.

That said, the code works fine. I'm only asking in case I've missed something.

By the way, I see that DriveType() returns 2 (floppy disk) for other types of removable drive, such as USB drives. It's not relevant to the present discussion, but might be worth keeping in mind.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Try this;
Once you have established the path; (m.driveroot) you can do a copy to it.
It will also give you volume info
Code:
Declare Integer GetLogicalDrives In Win32API
Declare Integer GetDriveType In Win32API String RootPath
Declare GetVolumeInformation In win32api String, String @, Integer, Integer @, Integer @, Integer @, String @, Integer

#Define DRIVE_REMOTE 4
#Define DRIVE_CDROM 5
m.drivelist = GetLogicalDrives()
For i = 0 To 31
	If Bittest(m.drivelist, i)
		m.DriveRoot = Chr(65 + i) + ":\"
		* perform a GetDriveType to determine if it's a floppy, CD, etc.
		m.drivetype = GetDriveType(m.DriveRoot)
		Do Case
				*!*	CASE m.drivetype = DRIVE_REMOTE
				*!*		m.drivestring = "Remote/Network drive"

			Case m.drivetype = DRIVE_CDROM
				m.drivestring = "CD-ROM drive"
		Endcase
		* perform a GetVolumeInformation

		m.RootPath = m.DriveRoot
		m.volname = Space(255)
		m.volnamelen = Len(m.volname)
		m.volumeserialnumber = 0
		m.maxfilenamelen = 0
		m.filesystemflags = 0
		m.filesystemname = Space(255)
		m.fsnamelen = Len(m.filesystemname)
		=GetVolumeInformation(m.RootPath, @m.volname, m.volnamelen, @m.volumeserialnumber, @m.maxfilenamelen, ;
			@m.filesystemflags, @m.filesystemname, m.fsnamelen)

		m.volname = Left(m.volname, At(Chr(0), m.volname) - 1)

	Endif

Endfor
? m.DriveRoot+" "+ m.drivestring+" "+m.volname
 
I think the problem is not to find the cd drive. The functionality wanted is burn files to a cd. If you would eg use COPY FILE to a cd drive, that would not be the same, as sending files to a cd drive, which puts them somewhere ready to burn to cd.

But there is a way to add cd burning functionality to your application, by using the Nero SDK:


Bye, Olaf.
 
Hi Mike,

You are calling GetLogicalDrives(), which I understand returns a bitmap of the logical drives, but you are not using the value that it returns.

Right. Don't need it. I was fooling around going somewhere and when I got what I wanted I just posted it. Didn't have time to clean it up.

pamela
 
Hello Knela: sorry my earlier post will not work if you have a Network drive:
Here is code that will work.
You will have to fine tune to suit your needs;
Code:
Declare Integer GetLogicalDrives In Win32API
Declare Integer GetDriveType In Win32API String RootPath
Declare GetVolumeInformation In win32api String, String @, Integer, Integer @, Integer @, Integer @, String @, Integer

#Define DRIVE_REMOTE 4
#Define DRIVE_CDROM 5
drivelist = GetLogicalDrives()
For i = 0 To 31
	If Bittest(drivelist, i)
		DriveRoot = Chr(65 + i) + ":\"
		* perform a GetDriveType to determine if it's a floppy, CD, etc.
		drivetype = GetDriveType(DriveRoot)
		Do Case
			Case drivetype = DRIVE_REMOTE
				drivestring = "Remote/Network drive"

			Case drivetype = DRIVE_CDROM
				drivestring = "CD-ROM drive"
				Exit
		Endcase
	Endif

Endfor
If drivetype = DRIVE_CDROM
	* perform a GetVolumeInformation
	RootPath = DriveRoot
	volname = Space(255)
	volnamelen = Len(volname)
	volumeserialnumber = 0
	maxfilenamelen = 0
	filesystemflags = 0
	filesystemname = Space(255)
	fsnamelen = Len(filesystemname)
	=GetVolumeInformation(RootPath, @volname, volnamelen, @volumeserialnumber, @maxfilenamelen, ;
		@filesystemflags, @filesystemname, fsnamelen)

	volname = Left(volname, At(Chr(0), volname) - 1)


	*? DriveRoot+" "+ drivestring+" "+volname

        ***** [b]Change "its.prg" with your file[/b]
	cFilename = Addbs(DriveRoot)+"its.prg"
	
        **** lets check if there is writable cd in drive
	If !Empty(volname)
		Copy File its.prg To (cFilename)
		If File(cFilename)
			=Messagebox("File copied",64,"CD Drive")
		Else
			=Messagebox("could not write to CD",64,"CD Drive")
		Endif
	Else
		=Messagebox("Insert a CD in "+DriveRoot+" "+ drivestring,64,"CD Drive")
	Endif
Else
	Wait "no cd rom drive found" Window Nowait
Endif

Olaf:
The copy to works on a formatted CD-RW, Have not tried it on a CD-R
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top