<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p>Turns out there may be no direct MS Windows call it seems for
associating an earlier VSN (Volume Serial Label) with its drive
letter. I was hoping that there might be a DigiKam .dll reference.</p>
<p>Here is a FreePascal unit for deriving this though. <br>
The logic may be of use for any one else doing SQL on the Sqlite3
DB(s) and needing to do this in another programming language as
well.</p>
<p>>>><br>
</p>
<p>unit VSN_to_Driveletter;<br>
<br>
{$mode ObjFPC}{$H+}<br>
<br>
interface<br>
<br>
uses<br>
{$IFDEF UNIX} {$IFDEF UseCThreads}<br>
cthreads, {$ENDIF} {$ENDIF}<br>
Classes, strutils, math, SysUtils, Windows, FileUtil;<br>
<br>
function FindVolumeSerial(const Drive: PChar): string;<br>
function
matchSerialToDriveLetter(serialNumberRequested:string):string;<br>
<br>
implementation<br>
<br>
<br>
function FindVolumeSerial(const Drive: PChar): string;<br>
{ Adapted from:<br>
<a class="moz-txt-link-freetext" href="http://delphi.about.com/od/windowsshellapi/a/volumeserial.htm">http://delphi.about.com/od/windowsshellapi/a/volumeserial.htm</a><br>
VSN - volume serial number<br>
}<br>
var<br>
VolumeSerialNumber: DWORD = 0;<br>
MaximumComponentLength: DWORD = 0;<br>
FileSystemFlags: DWORD = 0;<br>
SerialNumber: string;</p>
<p> begin<br>
FindVolumeSerial := '';<br>
<br>
// Function apparently returns true if all requested info is
retrieved (not 0 as MSDN suggests)<br>
if GetVolumeInformation(Drive, nil, 0, @VolumeSerialNumber,
MaximumComponentLength,<br>
FileSystemFlags, nil, 0) then<br>
FindVolumeSerial := IntToHex(HiWord(VolumeSerialNumber), 4)
+ '-' + IntToHex(LoWord(VolumeSerialNumber), 4);<br>
//
strictly correct to use - for Windows<br>
end;<br>
<br>
function matchSerialToDriveLetter(serialNumberRequested:string):
string;<br>
var<br>
Drive: char;<br>
DriveLetter, processSerial: string;</p>
<p>begin</p>
<p>{Adapted from<br>
<a class="moz-txt-link-freetext" href="http://delphi.about.com/cs/adptips1999/a/bltip0599_5.htm">http://delphi.about.com/cs/adptips1999/a/bltip0599_5.htm</a><br>
VSN - volume serial number<br>
}</p>
<p> serialNumberRequested :=
stringreplace(trim(serialNumberRequested),'-','',[rfReplaceAll]);<br>
<br>
matchSerialToDriveLetter := #0 ; // default - no VSN matched a
drive letter - Not Available<br>
// replace here with whatever
you need<br>
for Drive := 'A' to 'Z' do<br>
begin<br>
DriveLetter := Drive + ':\';<br>
processSerial :=
StringReplace(FindVolumeSerial(PChar(DriveLetter)),'-','',[]);<br>
<br>
if (UpperCase(serialNumberRequested) =
UpperCase(processSerial)) and (processSerial <> '') then<br>
exit (DriveLetter); // associated drive letter found
for VSN<br>
end;<br>
end;<br>
</p>
<p>{<br>
<a class="moz-txt-link-freetext" href="https://www.phind.com/search?cache=2d76e113-646a-42ed-b0bb-5a2874969310">https://www.phind.com/search?cache=2d76e113-646a-42ed-b0bb-5a2874969310</a><br>
<br>
<a class="moz-txt-link-freetext" href="https://superuser.com/questions/1646947/get-hard-drive-serial-number-based-on-drive-letter-on-windows-command-line-not">https://superuser.com/questions/1646947/get-hard-drive-serial-number-based-on-drive-letter-on-windows-command-line-not</a><br>
<br>
<a class="moz-txt-link-freetext" href="https://www.phind.com/search?cache=d2628ed7-066e-4570-9446-a826ad66d147">https://www.phind.com/search?cache=d2628ed7-066e-4570-9446-a826ad66d147</a><br>
<br>
<a class="moz-txt-link-freetext" href="https://forum.lazarus.freepascal.org/index.php?topic=18860.0">https://forum.lazarus.freepascal.org/index.php?topic=18860.0</a><br>
<br>
<a class="moz-txt-link-freetext" href="http://delphi.about.com/od/windowsshellapi/a/volumeserial.htm">http://delphi.about.com/od/windowsshellapi/a/volumeserial.htm</a><br>
}<br>
</p>
<p>end. <br>
</p>
<p><<< <br>
</p>
<p>Kind regards,</p>
<p>Paul</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 28/04/2023 2:46 am, Paul A. Norman
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:53BC2832-7C22-4B83-B2AC-1D17EDCA7170@paulanorman.info">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
So far my research suggests that this Album Root reference:
volumeid:?uuid=4261fb3f<br>
is actually a Windows NTFS 0x based number which may be called by
some – not so much a UUID, but:<br>
<br>
c:> fsutil fsinfo volumeinfo e:<br>
"Volume Serial Number : 0x4261fb3f<br>
<br>
There is also:<br>
<br>
c:> fsutil fsinfo volumeinfo e:<br>
"NTFS Volume Serial Number : 0x164262164261fb3f<br>
<br>
... which finishes with the same eight digits as the Volume Serial
Number <br>
<br>
And again the more usually used ...<br>
<br>
E:>>mountvol.exe<br>
...<br>
\\?\Volume{dd637aff-5761-4467-80c3-bfcb62c500e8}\<br>
E:\<br>
<br>
It seems to be a non trivial matter under Windows, to find the
drive letter associated with a “Volume Serial Number” as Digikam
is using.<br>
<br>
Some background...<br>
<br>
<a
href="https://www.digital-detective.net/documents/Volume%20Serial%20Numbers.pdf"
moz-do-not-send="true" class="moz-txt-link-freetext">https://www.digital-detective.net/documents/Volume%20Serial%20Numbers.pdf</a><br>
<br>
I can do a small FreePascal utility for this, but just needed to
ask first again, how or where is Digikam storing the root drive
letter, or how is it getting it from the “Volume Serial Number” =
volumeid:?uuid=xxxxxxxx <br>
stored as the album root(s) under Windows OS please?<br>
<br>
TIA<br>
<br>
Kind regards,<br>
Paul<br>
<br>
<br>
On 25/04/2023 7:02 pm, Paul Norman wrote:Volume Serial Number<br>
<br>
Apologies...<br>
<br>
done somehow in .ccp somewhere? :-)<br>
<br>
done somehow in .cpp somewhere?<br>
<br>
On 25/04/2023 3:01 pm, Paul Norman wrote:<br>
<br>
Hi,<br>
<br>
Under Windows you can normally do things like:<br>
<br>
E:>>mountvol.exe<br>
...<br>
\\?\Volume{dd637aff-5761-4467-80c3-bfcb62c500e8}\<br>
E:\<br>
<br>
And then ...<br>
<br>
start \\?\Volume{dd637aff-5761-4467-80c3-bfcb62c500e8}\<br>
<br>
And it would open the appropriate volume in File Explorer in my
case E:\ <br>
<br>
My entry in Digikam for the same drive shows in digikam4.>
AlbumRoots as:<br>
<br>
Identifier<br>
volumeid:?uuid=4261fb3f<br>
<br>
And obviously <br>
<br>
start \\?\Volume{4261fb3f}\<br>
<br>
— Is not going to work.<br>
<br>
How is: <br>
<br>
Digikam > Settings > Configure - digikam > Collections<br>
<br>
from only volumeid:?uuid=4261fb3f achieving showing drive E: as
the root please?<br>
<br>
Using Digikam as our prime DAM, I want to be able to query the
Sqlite (from Lazarus - FreePascal <a
href="https://www.lazarus-ide.org/" moz-do-not-send="true"
class="moz-txt-link-freetext">https://www.lazarus-ide.org/</a> )
and get the path to any image please.<br>
— I can do this so far using digikam4.db.> Albums and a lookup
from there on AlbumRoots > albumRoot , with digikam4.db.>
Images > album (etc.) and that gets me right up to getting the
correct drive letter (or \\?\Volume{<uuid>}\) under Windows.<br>
<br>
I have not yet found anything in the Digikam data .db(s),
digikam_systemrc or digikamrc, to cross-reference
volumeid:?uuid=4261fb3f with, and assume it must be being done
somehow in .ccp somewhere?<br>
<br>
Any pointers appreciated please.<br>
<br>
Kindest regards,<br>
<br>
Paul
<hr><a href="https://PaulANorman.info" moz-do-not-send="true">https://PaulANorman.info</a><br>
</blockquote>
</body>
</html>