Solved

Change the volumelabel of a drive?

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
find a node in VST 2 81
Magic Software info 18 145
Firemonkey webbrowser scrollbars ? 1 57
Firemonkey how to swip panel with finger tap 1 25
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

696 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