Home » Community » Newbie corner » Get volume name of shares ... (Try to get a shares volume name)
Get volume name of shares ... [message #56207] |
Mon, 08 February 2021 22:11  |
dschoni
Messages: 15 Registered: January 2021 Location: Switzerland
|
Promising Member |
|
|
Is there a simple way to get the volume name of a share?
First I tried to use the SysInfo packages GetDriveInformation() from bazaar. But it seems to be rather old and does not work. If I compile it, I get errors:
SysInfo.h (274): error: no type named 'mt19937' in namespace 'std'.
I've got no idea, how to fix that. Basically I couldn't find any usefull method to get the required informations.
Best Regards, Daniel.
|
|
|
|
Re: Get volume name of shares ... [message #56210 is a reply to message #56207] |
Mon, 08 February 2021 23:18   |
dschoni
Messages: 15 Registered: January 2021 Location: Switzerland
|
Promising Member |
|
|
I'm using a tree and some modifications on the library files:
----------------------------------------------------------------------------------------
used mods
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
FileSel.h: adding
----------------------------------------------------------------------------------------
Image GetDirIcon(const String& s);
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
CtrlLib.h:
----------------------------------------------------------------------------------------
#define NEWSTYLE
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
TreeCtrl.cpp:1023
----------------------------------------------------------------------------------------
if(yh >= 0 && yl < sz.cy) {
int x = levelcx + levelcx * l.level + levelcx2 - org.x;
#ifdef NEWSTYLE
#else
w.DrawRect(x, yl, 1, yh - yl, SColorShadow);
#endif
}
TreeCtrl.cpp:1051
if(w.IsPainting(0, y, sz.cx, msz.cy) && msz.cy > 0) {
if (multiroot) {
if(m.canopen || m.child.GetCount()) {
#ifdef NEWSTYLE
Image im = m.isopen ? CtrlImg::SmallDown() : CtrlImg::SmallRight();
#else
Image im = m.isopen ? CtrlImg::treeminus() : CtrlImg::treeplus();
#endif
op -= CtrlImg::cross().GetSize() / 2;
w.DrawImage(op.x, op.y, imgEmpty);
}
}
else {
#ifdef NEWSTYLE
#else
w.DrawRect(op.x, op.y, levelcx2, 1, SColorShadow);
#endif
if(m.canopen || m.child.GetCount()) {
#ifdef NEWSTYLE
Image im = m.isopen ? CtrlImg::SmallDown() : CtrlImg::SmallRight();
#else
Image im = m.isopen ? CtrlImg::treeminus() : CtrlImg::treeplus();
#endif
op -= im.GetSize() / 2;
w.DrawImage(op.x, op.y, im);
}
}
w.DrawImage(x, y + (msz.cy - isz.cy) / 2, m.image);
x += isz.cx;
Color fg, bg;
dword st;
Size csz = m.GetCtrlSize();
if(m.ctrl && !highlight_ctrl) // 2008-04-08 mrjt
x += csz.cx;
if(x < sz.cx) {
const Display *d = GetStyle(i, fg, bg, st);
int ctx = highlight_ctrl * csz.cx;
Rect br = RectC(x, y, vsz.cx + 2 * m.margin + ctx, msz.cy);
if(!IsNull(m.value) || m.ctrl && highlight_ctrl) {
#ifdef NEWSTYLE
#else
w.DrawRect(br, bg);
#endif
Rect r = RectC(x + ctx + m.margin, y + (msz.cy - vsz.cy) / 2, vsz.cx, vsz.cy);
w.Clip(r);
d->Paint(w, r, m.value, fg, bg, st);
w.End();
}
if(i == cursor && !nocursor && multiselect && GetSelectCount() != 1 && HasFocus()
&& !IsDragAndDropTarget())
DrawFocus(w, br, st & Display::SELECT ? SColorPaper() : SColorText());
}
}
----------------------------------------------------------------------------------------
If there is an easier way to modify the tree, I would be glad to hear.
Best Regards, Daniel
[Updated on: Mon, 08 February 2021 23:19] Report message to a moderator
|
|
|
|
|
Re: Get volume name of shares ... [message #56217 is a reply to message #56215] |
Wed, 10 February 2021 16:44   |
dschoni
Messages: 15 Registered: January 2021 Location: Switzerland
|
Promising Member |
|
|
Dear koldo
Quote:
SysInfo is maintained and tested daily. Please tell me in what environment you have that error and I will solve it.
I've just opened "bazaar/SysInfo_demo_gui", then compiled it (Execute button) on the freshly installed Upp TheIDE Version 15260 (CLANGx64 Debug).
My System:
Edition Windows 10 Pro
Version 20H2
Build 19042.746
Feature Experience Pack 120.2212.551.0
It throws me over 20 errors, one of it is the one with "mt19937".

Best Regards, Daniel
[Updated on: Wed, 10 February 2021 16:55] Report message to a moderator
|
|
|
|
|
|
Re: Get volume name of shares ... [message #56225 is a reply to message #56217] |
Thu, 11 February 2021 08:39   |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
dschoni wrote on Wed, 10 February 2021 16:44Dear koldo
Quote:
SysInfo is maintained and tested daily. Please tell me in what environment you have that error and I will solve it.
I've just opened "bazaar/SysInfo_demo_gui", then compiled it (Execute button) on the freshly installed Upp TheIDE Version 15260 (CLANGx64 Debug).
My System:
Edition Windows 10 Pro
Version 20H2
Build 19042.746
Feature Experience Pack 120.2212.551.0
It throws me over 20 errors, one of it is the one with "mt19937".

Best Regards, Daniel
Dear dschoni
Reading the error list I find that:
- Although SysInfo calls Bazaar/Functions4U, it seems that your compiler cannot find Functions4U.h
- The line numbers of the errors in SysInfo.h don't match with the lines in the actual code
In summary, it may be that you are using and old version of SysInfo, and you do not have Functions4U in your sources. Please tell me from where you have installed Bazaar (SVN, UppHub, nightly builds).
Thank you for your report.
Best regards
Iñaki
|
|
|
Re: Get volume name of shares ... [message #56251 is a reply to message #56225] |
Sun, 14 February 2021 13:52   |
dschoni
Messages: 15 Registered: January 2021 Location: Switzerland
|
Promising Member |
|
|
Dear koldo
Quote:In summary, it may be that you are using and old version of SysInfo, and you do not have Functions4U in your sources. Please tell me from where you have installed Bazaar (SVN, UppHub, nightly builds).
I've installed the stable release, posted on the website https://www.ultimatepp.org/www$uppweb$download$en-us.html
This leads to SOURCEFORGE https://sourceforge.net/projects/upp/files/ where I installed the latest release https://sourceforge.net/projects/upp/files/latest/download
So I used the Bazaar examples, like these were installed with Upp.
Best Regards, Daniel
[Updated on: Sun, 14 February 2021 17:26] Report message to a moderator
|
|
|
Re: Get volume name of shares ... [message #56252 is a reply to message #56222] |
Sun, 14 February 2021 14:21   |
dschoni
Messages: 15 Registered: January 2021 Location: Switzerland
|
Promising Member |
|
|
Dear Mirek
Quote:Nope, you do Find with empty path and then you get it in FileInfo::root_desc.
This works on a fixed disk drive, but not on a network share.
I've tried:
void FolderTree::AddSystemPlaces(int id)
{
Array<FileSystemInfo::FileInfo> root;
FileSystemInfo fs;
#ifdef PLATFORM_WIN32
root = fs.Find("",1000,false);
for(int i = 0; i < root.GetCount(); i++) {
String desc = root[i].root_desc;
String n = root[i].filename;
if(n != "A:\\" && n != "B:\\") {
#ifdef PLATFORM_WIN32
if(*n.Last() == '\\')
n.Trim(n.GetCount() - 1);
#endif
String type;
int maxName;
if(desc.GetCount() == 0) {
GetDriveInformation(n, type, desc, maxName, type);
if (desc == "") desc << " " << t_("Local Disk");
}
desc << " (" << n << ")";
AddPlace(id, GetDriveImage(root[i].root_style), root[i].filename, desc);
}
}
if(GetSystemMetrics(SM_REMOTESESSION))
for(int drive = 'A'; drive < 'Z'; drive++) {
String path = Format("\\\\tsclient\\%c", drive);
if(FindFile(path + "\\*.*"))
AddPlace(id, path, Format(t_("%c on client"), drive));
}
#endif
#ifdef PLATFORM_POSIX
root = fs.Find("/media/*",1000,false);
for(int i = 0; i < root.GetCount(); i++) {
String fn = root[i].filename;
if(*fn != '.' && fn.Find("floppy") < 0)
AddPlace(id, "/media/" + fn, fn);
}
AddPlace(id, "/", t_("Computer"));
#endif
}
After
String desc = root[i].root_desc;
String n = root[i].filename;
"desc" contains the value "Document" at my fixed disk drive "D:" which is the volume name.
"n" contains "D:\\".
If I go further to "M:", which is a network share and the volume name is "Media", i've got:
"desc" contains "".
"n" contains "M:\\".

This is why I've copied "GetDriveInformation" from the SysInfo-package to my code and used Quote:
GetDriveInformation(n, type, desc, maxName, type); if "desc" is empty.
After "GetDriveInformation" "desc" contains "Media".
Best Regards, Daniel
|
|
|
|
|
Goto Forum:
Current Time: Sun Apr 27 18:22:01 CEST 2025
Total time taken to generate the page: 0.03525 seconds
|