Author Topic: get current drive volume label  (Read 12151 times)

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
get current drive volume label
« on: February 22, 2008, 03:21:21 pm »
hi

i have been trying to get the current open buffer "file" Drive Volume  label:

1- Is there a ready made function i can call and returns a string?

or

2- Can someone plz tell me why s is always empty

_command void vol() name_info(',')
{
   int status;
   _str s=_PipeShellResult("vol",status);
   message(s);  // always is empty
}

hope someone helps.

Thanks

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4924
  • Hero Points: 402
Re: get current drive volume label
« Reply #1 on: February 22, 2008, 08:28:32 pm »
Try 'c:\windows\system32\cmd /c vol'.  I haven't used this pipe function but I suspect it doesn't understand cmd.exe internal commands.

Graeme

  • Senior Community Member
  • Posts: 2363
  • Hero Points: 311
Re: get current drive volume label
« Reply #2 on: February 22, 2008, 08:39:14 pm »
I was trying this at the same time as Clark answered so just in case it helps, I found that _PipeProcess returns "File not found" for a command string of "vol".  If I change "vol" to the name of a batch file in the current directory it runs the batch file and returns the first "line" of output from the batch file. i.e.

Code: [Select]
_command void myvol() name_info(',')
{
   int status;
  _str s=_PipeShellResult('gp1.bat' ,status);
  _message_box('hello ' :+ s);
   //int hin, hout, herr;
   //int hprocess = _PipeProcess('gp1.BAT ',hin,hout,herr,'C');
   //if( hprocess<0 ) {
      // Error
     // status=hprocess;
      //return "";
   //}
   //get_message(hprocess);
//   _message_box('hello ' :+ hprocess :+ ' ' :+ get_message(hprocess)); 
}


When gp1.bat contains the following
@echo off
vol

the _message_box call shows something like "volume in drive D is temp"  (looks like I didn't give drive D  a sensible name!)

Graeme

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: get current drive volume label
« Reply #3 on: February 22, 2008, 08:44:51 pm »
Excellent ....  :D

i am now using a bat file like Graeme had

thanks the both of you

Regards
ehab