Solved

Change the volumelabel of a drive?

Posted on 1998-08-13
2
920 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Expert Comment

by:pjdb
ID: 1362038
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
ID: 1362039
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month5 days, 10 hours left to enroll

626 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