Win32 - Rename Disk/HD Drive

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Win32 - Rename Disk/HD Drive

Post by BackupUser »

Code updated for 5.20+

Restored from previous forum. Originally posted by MrVainSCL.

This is a very small Win32 routine to rename your disk/harddrives for whatever you will need.

Here is a normal version:

Code: Select all

; ------------------------------------------------------------
;
; PureBasic Win32 API - RenameDrive - Example v1.0
;
; by MrVainSCL! aka Thorsten   21/Jan/2003    PB v3.51+
;
; ------------------------------------------------------------
;
result = SetVolumeLabel_("c:\", "PurePower")
;
If result = 1
  MessageRequester("","Drive succesfull renamed",0)
Else
  MessageRequester("","Couldnt rename Drive",0)
EndIf
End
;
; ------------------------------------------------------------
Here is a Procedure() version:

Code: Select all

; ------------------------------------------------------------
;
; PureBasic Win32 API - RenameDrive - Example v1.0
;
; by MrVainSCL! aka Thorsten   21/Jan/2003    PB v3.51+
;
; ------------------------------------------------------------
;
Procedure RenameDrive(drive$,name$)
  result = SetVolumeLabel_(drive$, name$)
  ProcedureReturn result
EndProcedure
;
; -------- Check if user is connected to a network -------- 
;
If RenameDrive("c:\","PurePower") = 1
  state$ = "Drive succesfull renamed."
Else
  state$ = "Couldnt rename Drive"
EndIf
;
MessageRequester("Result of renaming drive:",state$,0)
End
;
; ------------------------------------------------------------

Remarks
Windows 95/98/Me: SetVolumeLabelW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.

Requirements
Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, Windows 95.
Server: Included in Windows Server 2003, Windows 2000 Server, Windows NT Server.



greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TheBeck.

You can also do this to use one less variable and make your source more readable and smaller:

Code: Select all

If SetVolumeLabel_("c:\", "PurePower")
    MessageRequester("","Drive succesfull renamed",0)
  Else
    MessageRequester("","Couldnt rename Drive",0)
  EndIf
End
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

TheBeck:
Yes i know.. but i wrote it with one more variable, so everybody (esp. newbies) will understand it in all parts too... Sometimes more is better :wink:


greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

> Remarks
> Windows 95/98/Me: SetVolumeLabelW is supported by the Microsoft Layer for Unicode. To use
> this, you must add certain files to your application, as outlined in Microsoft Layer for
> Unicode on Windows 95/98/Me Systems.

You don't need to mention that. As PureBasic doesn't support UNICODE, all those API calls are not supported, too.

BTW: I don't think it is necessary to write a Tip here for each of those little API calls, there are thousands of them, and if someone needs them, he can easily find the Information he needs in any API manual.

I don'd want to offend you, but there are thousends of API calls, and if you write one here every day, it is going to get really annoying.

Anyway, keep cool...

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

You can convert ansi 2 unicode with some api`s.

see for example:

http://www.reelmediaproductions.com/pb/ ... etSend.zip

Its a long way to the top if you wanna .....CodeGuru
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.
Originally posted by freak
BTW: I don't think it is necessary to write a Tip here for each of those little API calls, there are thousands of them, and if someone needs them, he can easily find the Information he needs in any API manual.

I don'd want to offend you, but there are thousends of API calls, and if you write one here every day, it is going to get really annoying.

Anyway, keep cool...

Timo
I agree with Timo completely, this forum is not a replacement for MSDN or API docs :)

Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Ok dudes... no problem... i only wanted try to help some people (esp. newbies)...
For future i know what to do!


greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

You're doing preventive help, it was no question :).

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Sorry Timo and Berikco I have to disagree.

Don't want to offend anybody, but I think that such comments are really bad for the community.

I don't know which code status MrVain has (beginner/average/pro or whatever...) I don't care.
And I don't care if his tips are short, medium, or long and how much API calls he uses or not, or if he gives only examples how to use API calls.
I don't care!

With your comments you only discourage others to share her findings/code, may they be little or big.

PureBasic is not for pro coder only. The homepage says:

PureBasic has been created for the beginner and expert alike.

Period!

If beginners are looking for a good language and they go to trick&tips in the forum, it's good that they find pro stuff and easy stuff.
Every beginner, that not chooses PureBasic because the examples are too pro style and they don't get what the code is doing, and therefore they choose another language is a cut in Fred's wallet.

If there are thousends of API calls and he likes to share his hints for beginners, let him doing it - it's his time that he invests.
If it's annoying for you than you don't have to read it.

Don't discourage others to be a active part of the community.

Again, I don't want offend anybody, that's for sure :)


Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.

Franco.

Only problem is, in 3 weeks, all this posts are gone, new users can't find them, because they don't know the exact phrase off the API call.
Just search the forum now on "API" none of these tips is listed in the first results page.

In my opinion, this is stuff for an API tutorial that belongs on http://www.purebasic.com
As CHM help file, new users wil have much more benifit from it.
What you guys think about this.....MrVain, Fred?

Just my personal opinion...
And I don't want to offend anybody, that's for sure :)



Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

Ok Franco, you're right. Maybe i was to fast with writing my post. It just looked to me like MrVain was going to write those tips every day now. (And that would really blow up this forum)

So my suggestion now is, to collect them a bit, and post more of them in a few bigger posts. (Or even do a Tutorial)

I want to say again, that i don't want to stop anybody from posting here, sorry if it sounded like that.

@Berikco and ALL

> Only problem is, in 3 weeks, all this posts are gone, new users
> can't find them, because they don't know the exact phrase off the
> API call. Just search the forum now on "API" none of these tips is
> listed in the first results page.

That is true, and especially in the Tips section it is important to find what you're looking for.

My suggestion is, that everybody appends a short Sections with Keywords at the end of his post, that describe what his code does.

As Berikco said, if there is only Code posted, people will hardly type the correct API Command name, if they search for a Tip.

So this would improve search results for everyone of us.

--

That's it...

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

@ Berikco & Freak
I can understand your point.

The only thought I have is to encourage users to be a active part of this community, not to discourage them.

I like Berikco's idea of a kind of tutorial.
But why not split tips&tricks in the forum ?

Don't know if it's possible to do it, but there could be a Tips&Tricks Topic on the main site.
If you click on it you come to the next page with the different sub-topics like:

Database
Gadgets
Internet
Linked List
Win-API
etc.

and there everybody can throw his tip in there - and all is organized.
After a few weeks we have a nice tutorial.

Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TheBeck.

> Don't want to offend anybody, but I think that such comments are really bad for the community.

I agree 100% Franco. MrVainSCL I hope you have not been discouraged to contribute.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Posting a message that shows how to use 1 API command
isnt a tip nor a trick, IMHO.
freak and Berikco didnt say MrVain should stop posting,
they only said its not much useful to post such small
things that show how to use 1 command.
There are over 8.000 WinAPI functions you can use with
PB and they are explained in _free_ references like
MS Platform SDK and Win32.hlp - so what is the
tip or trick here ??
(imho a tip or trick shows something _special_)

Maybe we should just post 200 MB WinAPI documentation
in this board section?
Would be nearly the same, maybe you understand.

MrVain: Keep up the _good_ work, which means dont
post articles without giving credits to the original autor.
(you know, thats the reason i dont like you :))

Except such small things the community is going well, so...

cya,
...Danilo
(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Max..

Probably the folder is not appropriate, but generally I like even such WinAPI "snippets".

Often enough I just browse them and notice stuff that might be useful _later_.

It's hard to search for anything, if you don't know it exists, you know... :) easier if you have a slight hint in mind already...

To put my rant into a nutshell: may the forum master create a folder WinAPI and all can live happily until eternity.

@ Danilo

Maybe we all should post from now on whom we like and whom we don't. In my case the list would be longer than the "200 MB Win API documentation" :)

Max.
Post Reply