Quantcast
Channel: VBForums - API
Viewing all articles
Browse latest Browse all 207

CreateFile returns Incorrect function

$
0
0
I get a list of physical disks with wmic diskdrive list command. There are two internal SSDs, one USB flash drive and one external SSD connected to USB-C port. CreateFile works for all of them except for external SSD, I get ERROR_INVALID_FUNCTION. When I connect the same SSD to USB port, it works as expected. What could be the problem?

I found some suggestions to look into IRP_MJ_CREATE, but there is no info how to use in VB.NET.

Code:

Dim result = CreateFile("\\.\PHYSICALDRIVE2", EFileAccess.GenericRead Or EFileAccess.GenericWrite, EFileShare.Read Or EFileShare.Write, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.Normal, IntPtr.Zero)
If result.IsInvalid Then
    Console.WriteLine(New Win32Exception(Marshal.GetLastWin32Error()).Message)
End If


Viewing all articles
Browse latest Browse all 207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>