Solved

Change the volumelabel of a drive?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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