Solved

Change the volumelabel of a drive?

Posted on 1998-08-13
2
888 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
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

803 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