I need to know the serial of a volume shared with smb in c++. I get this id from Windows using GetVolumeInformation. In Linux I get the same from the bash, using
$ smbclient '\\<ip>\<share>' -c volume
How can I get the same in C++?
You could link your code with the samba
package, and imitate what smbclient
tool is doing. You can find it here: https://github.com/samba-team/samba/blob/master/source3/client/client.c#L4423
But the easy and reasonable thing will be to call this shell command directly from your program and read the output using popen
. See an example
here:
How do I execute a command and get the output of the command within C++ using POSIX?