Solved

Change the volumelabel of a drive?

Posted on 1998-08-13
2
866 Views
Last Modified: 2012-08-14
I want my program to change the volumelabel of a drive.

I think SetVolumeLabel in windows.pas should do the job but
cant get it to work...

function SetVolumeLabel(lpRootPathName: PChar; lpVolumeName: PAnsiChar): BOOL; stdcall;

Please finish my procedure:

Procedure SetVolumeLabel(DriveChar, LabelName: String);
Begin
  SetVolumeLabel(DriveChar, LabelName);
end;

0
Comment
Question by:mko0
2 Comments
 
LVL 1

Expert Comment

by:pjdb
Comment Utility
Try this one :
SetVolumeLabel(DriveChar[1], @LabelName[1]);
since a String is nothing more than an array of char...

or SetVolumeLabel(DriveChar[1], PChar(LabelName)); if you prefer

JDB
0
 
LVL 1

Accepted Solution

by:
EmmDieh earned 170 total points
Comment Utility
This procedure should
work if your are using long strings. {$h+}
Procedure SetVolumeLabel(DriveChar, LabelName: String);
Begin
  SetVolumeLabel(PChar(DriveChar), PChar(LabelName));
end;
SetVolumeLabel('c:\', 'NewName');
if you are using short strings:
Procedure SetVolumeLabel(DriveChar, LabelName: String);
Begin
  DriveChar := DriveChar + #0;
  LabelName := LabelName + #0;
  SetVolumeLabel(@DriveChar[1], @LabelName[1]);
end;

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now