I currently use GetVolumeInformation to store an ID for each user (a quick way to see how many computers the user has installed my app). My issue is I've now converted across to C# from VB.net and I get different values being returned.

This is the old VB.net code that returns 391637000 on my PC.
vb Code:
  1. Private Declare Ansi Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" ( _
  2.         ByVal lpRootPathName As String, _
  3.         ByVal lpVolumeNameBuffer As StringBuilder, _
  4.         ByVal nVolumeNameSize As Int32, _
  5.         ByRef lpVolumeSerialNumber As Int32, _
  6.         ByRef lpMaximumComponentLength As Int32, _
  7.         ByRef lpFileSystemFlags As Int32, _
  8.         ByVal lpFileSystemNameBuffer As StringBuilder, _
  9.         ByVal nFileSystemNameSize As Int32) As Boolean
  10.  
  11.  
  12.  Dim r As Boolean
  13.         Dim iSerial As Integer
  14.         Dim p_hardDiskId As String
  15.         Dim sbVolumeName As New StringBuilder(256)
  16.         Dim sbFileSystemName As New StringBuilder(256)
  17.         Dim systemDrive As String
  18.  
  19.        systemDrive = Environment.GetEnvironmentVariable("SystemDrive") & "\"
  20.  
  21.             r = GetVolumeInformation(systemDrive, sbVolumeName, sbVolumeName.Capacity, iSerial, 0, 0, sbFileSystemName, sbFileSystemName.Capacity)
  22.             p_hardDiskId = Math.Abs(iSerial).ToString

However, after converting the above code to C# it now returns 3903330296.
C# Code:
  1. [DllImport("kernel32.dll")]
  2.         private static extern long GetVolumeInformation(string PathName, StringBuilder VolumeNameBuffer, UInt32 VolumeNameSize, ref UInt32 VolumeSerialNumber, ref UInt32 MaximumComponentLength, ref UInt32 FileSystemFlags, StringBuilder FileSystemNameBuffer, UInt32 FileSystemNameSize);
  3.  
  4. uint serNum = 0;
  5.             uint maxCompLen = 0;
  6.                 UInt32 volFlags = new UInt32();
  7.                 StringBuilder volInfoString = new StringBuilder(256);
  8.                 StringBuilder fileSystemName = new StringBuilder(256);
  9.                 string systemDrive = Environment.GetEnvironmentVariable("SystemDrive") + "\\";
  10.                 long volInfo = GetVolumeInformation(systemDrive, volInfoString, (UInt32)volInfoString.Capacity, ref serNum, ref maxCompLen, ref volFlags, fileSystemName, (UInt32)fileSystemName.Capacity);
  11.                 serNum = (uint)Math.Abs(serNum);

I can't work out why/how a different value can be returned using the same function??

Anyone seen this issue before?