Getting Drive Details From HikVision SDK

TraeB

n3wb
Joined
Jun 29, 2023
Messages
1
Reaction score
0
Location
Australia
Hello all, I am new to the forum so im going to apologies in advance if this is the wrong thread. However I am having issues getting my head around the Hikvision API.
I have a method that logs into the Hikvision camera remotely however when I go to receive the drive details it spits out multiple drives which I know don't exist. The camera I'm logging into has a SD card installed and is not connected to an NVR.

If you can spot anything or have some insight on how to get this information from the lib it would be a great help :)

Cheers!

Code:
NET_DVR_DISKSTATE[] diskStates = new NET_DVR_DISKSTATE[MAX_DISKNUM_V30];
            int bufferSize = Marshal.SizeOf(typeof(NET_DVR_DISKSTATE)) * MAX_DISKNUM_V30;
            IntPtr buffer = Marshal.AllocHGlobal(bufferSize);
            int bytesReturned;

            bool success = NET_DVR_GetDVRConfig(userID, 100, 0, buffer, bufferSize, out bytesReturned);
            if (success)
            {
                for (int i = 0; i < MAX_DISKNUM_V30; i++)
                {
                    NET_DVR_DISKSTATE diskState = (NET_DVR_DISKSTATE)Marshal.PtrToStructure(buffer + i * Marshal.SizeOf(typeof(NET_DVR_DISKSTATE)), typeof(NET_DVR_DISKSTATE));
                    if (diskState.dwVolume > 0)
                    {
                        Console.WriteLine("Disk {0}:", i);
                        Console.WriteLine("  Volume: {0} MB", diskState.dwVolume);
                        Console.WriteLine("  Free Space: {0} MB", diskState.dwFreeSpace);
                        Console.WriteLine("  Capacity: {0} MB", diskState.dwHardDiskStatic);
                    }
                }
            }
            else
            {
                Console.WriteLine("Failed to retrieve storage information. Error code: " + NET_DVR_GetLastError());
            }

            / Log
            / Log out to release resources (optional)
            NET_DVR_Logout(userID);
            return true;
 

Attachments

Top