Anthony's VBA Forum Index Anthony's VBA Forum
Where the knowledge is shared
Menu
 Anthony's VBA Forum IndexHome Page
 Anthony's VBA Forum IndexForum Index
FAQFAQ
MemberlistMemberlist
UsergroupsUsergroups
RegisterRegister
ProfileProfile
Log in to check your private messagesMessages
Log inLogin/Out

Quick Search

Advanced Search

Links
Consulting
Products

Who's Online
[ Administrator ]
[ Moderator ]


RECOGNISE CD VOLUME LABEL - VB CODE

 
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA
View previous topic :: View next topic  
Author Message
bit of byte



Joined: 16 Jan 2005
Posts: 1

PostPosted: Sun Jan 16, 2005 8:12 pm    Post subject: RECOGNISE CD VOLUME LABEL - VB CODE Reply with quote

Hello all you nerds!

I have code in C++ I wish to convert to VB.

Basically, I wish to recognise the CD volume label using VB..

Can anyone please provide the equivalent VB code using the C++ code given below?

public
{ Public declarations}
function GetCDLetter: string;
function GetCDLabel(Drive: string): string;
end;

var
Form1: Tform1;
Implementation
{SR *.DFM}
procedure Tform1.Button1Click(Sender: TObject);
begin
Label1.Caption:=GetCDLabel(GetCDLetter());
end;
function TForm1.GetCDLetter: string;

var
N: Byte;
Drv: string;
Drives: set of 0..25;
begin
Integer(Drives):=GetLogicalDrives;
For N:=0 to 25 do

If N in Drives then
begin
Drives:=Char(N+Ord(‘A’))+’:\’;
If(GetDriveType(Pchar(Drv))=5) then
begin
Result:=Drv;
Exit;
end;
end;
end;

function Tform1.GetCDLabel(Drive: string): string;
var
VolumeName: array[0..255] of Char;
FileSystemType: array[0..255] of Char;
SerialNum: DWORD;
MaxFilenameLength: DWORD;
Flage: DWORD;
Begin

If (GetVolumeInformation(Pchar(Drive),VolumeName,256,@SerialNum,MaxFilenameLength,Flags,FileSystemType,256)) then Result: =VolumeName
Else Result:=’No CD Present’;
end;
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group