Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
dschoni is currently offline  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 #56208 is a reply to message #56207] Mon, 08 February 2021 22:31 Go to previous messageGo to next message
dschoni is currently offline  dschoni
Messages: 15
Registered: January 2021
Location: Switzerland
Promising Member
Well, it seems, I've got the solution Laughing
index.php?t=getfile&id=6370&private=0
I've copied the whole GetDriveInformation(...) function to my code.

Best Regards, Daniel

P.S.
It's getting more and more interesting.
The GetDriveInformation is based on GetVolumeInformation, which is also used in Path/FileSystemInfo::Find, but unfortunately this function does not read out the volume name.
I found also that the GetVolumeInformation function is part of winbase.h and fileapi.h, which both are included in Upp Rolling Eyes - this gives me ideas to work on ...

[Updated on: Mon, 08 February 2021 23:02]

Report message to a moderator

Re: Get volume name of shares ... [message #56210 is a reply to message #56207] Mon, 08 February 2021 23:18 Go to previous messageGo to next message
dschoni is currently offline  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 #56215 is a reply to message #56207] Tue, 09 February 2021 22:00 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3377
Registered: August 2008
Senior Veteran
dschoni wrote on Mon, 08 February 2021 22:11
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.
Hi dschoni

SysInfo is maintained and tested daily. Please tell me in what environment you have that error and I will solve it.

Thank you.


Best regards
Iñaki
Re: Get volume name of shares ... [message #56216 is a reply to message #56207] Wed, 10 February 2021 15:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13994
Registered: November 2005
Ultimate Member
dschoni wrote on Mon, 08 February 2021 22:11
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.



Check CtrlLib/FileSel.cpp:507. StdFileSystemInfo is in Core...
Re: Get volume name of shares ... [message #56217 is a reply to message #56215] Wed, 10 February 2021 16:44 Go to previous messageGo to next message
dschoni is currently offline  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".
index.php?t=getfile&id=6371&private=0

Best Regards, Daniel

[Updated on: Wed, 10 February 2021 16:55]

Report message to a moderator

Re: Get volume name of shares ... [message #56219 is a reply to message #56216] Wed, 10 February 2021 18:08 Go to previous messageGo to next message
dschoni is currently offline  dschoni
Messages: 15
Registered: January 2021
Location: Switzerland
Promising Member
Thank you, mirek

Quote:
Check CtrlLib/FileSel.cpp:507. StdFileSystemInfo is in Core...


I see, StdFileSystemInfo is in Core/Path.cpp, but the volume name is just private.

index.php?t=getfile&id=6372&private=0

So it's required to use GetVolumeInformation directly, to get the desired information.

But thanks a lot, your answers do help me, to learn about the system.
Best Regards, Daniel
Re: Get volume name of shares ... [message #56221 is a reply to message #56217] Wed, 10 February 2021 20:33 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3377
Registered: August 2008
Senior Veteran
dschoni wrote on Wed, 10 February 2021 16:44
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".
index.php?t=getfile&id=6371&private=0

Best Regards, Daniel

Hello dschoni

This is really weird. My base system is similar to yours.
Does anybody could compile Bazaar/SysInfo under CLANG in Windows 10 to try to reproduce this error?
Thank you!


Best regards
Iñaki
Re: Get volume name of shares ... [message #56222 is a reply to message #56219] Wed, 10 February 2021 21:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13994
Registered: November 2005
Ultimate Member
dschoni wrote on Wed, 10 February 2021 18:08
Thank you, mirek

Quote:
Check CtrlLib/FileSel.cpp:507. StdFileSystemInfo is in Core...


I see, StdFileSystemInfo is in Core/Path.cpp, but the volume name is just private.


Nope, you do Find with empty path and then you get it in FileInfo::root_desc.

Mirek
Re: Get volume name of shares ... [message #56225 is a reply to message #56217] Thu, 11 February 2021 08:39 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3377
Registered: August 2008
Senior Veteran
dschoni wrote on Wed, 10 February 2021 16:44
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".
index.php?t=getfile&id=6371&private=0

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 Go to previous messageGo to next message
dschoni is currently offline  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 Go to previous messageGo to next message
dschoni is currently offline  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:\\".

index.php?t=getfile&id=6375&private=0

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
Re: Get volume name of shares ... [message #56263 is a reply to message #56251] Mon, 15 February 2021 08:18 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3377
Registered: August 2008
Senior Veteran
Dear Daniel

As far as I can see, updated Bazaar can only be obtained from svn. Please try to download the packages from there, as UppHub is still in preparation.
Mixing updated U++ with old Bazaar packages may produce errors.


Best regards
Iñaki
Re: Get volume name of shares ... [message #56268 is a reply to message #56263] Mon, 15 February 2021 11:21 Go to previous message
mirek is currently offline  mirek
Messages: 13994
Registered: November 2005
Ultimate Member
For what is worth:

- I have checked UppHub SysInfo and it works without problems (so it should work in nightly build)

- I have also fixed FileSystemInfo::Find to return correct network volume names.
Previous Topic: CallbackN<> storing pointer to member function
Next Topic: [Solved]Vector<Vector<int>> problem
Goto Forum:
  


Current Time: Fri Jul 19 11:54:55 CEST 2024

Total time taken to generate the page: 0.01308 seconds