Retrieving dbcc_name string from a DEV_BROADCAST_DEVICEINTERFACE structure

J

jan axelson

My application is using RegisterDeviceNotification() to detect
attachment and removal of a USB HID-class device.

The form is receiving WM_DEVICECHANGE messages with wParam set to
DBT_DEVICEARRIVAL or DBT_DEVICEREMOVECOMPLETE.

I want to identify the device that has arrived or been removed by
examining the dbcc_name member of the DEV_BROADCAST_DEVICEINTERFACE
structure.

This is my declaration for DEV_BROADCAST_DEVICEINTERFACE:

<StructLayout(LayoutKind.Sequential)> _
Public Structure DEV_BROADCAST_DEVICEINTERFACE
Dim dbcc_size As Integer
Dim dbcc_devicetype As Integer
Dim dbcc_reserved As Integer
Dim dbcc_classguid As Guid
Dim dbcc_name As Short
End Structure

This is my code to call RegisterDeviceNotification:

Dim dbi As New DEV_BROADCAST_DEVICEINTERFACE
Dim size As Integer
size = Marshal.SizeOf(dbi)
dbi.dbcc_size = size
dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE
dbi.dbcc_reserved = 0
dbi.dbcc_classguid = HidGuid 'obtained with HidD_GetHidGuid()
dbi.dbcc_name = 0
Dim buffer As IntPtr = Marshal.AllocHGlobal(size)
Marshal.StructureToPtr(dbi, Buffer, True)
Dim r As IntPtr
r = RegisterDeviceNotification(frmMy.Handle, buffer,
DEVICE_NOTIFY_WINDOW_HANDLE)

This is (a portion of) the WndProc subroutine:

Protected Overrides Sub WndProc(ByRef m As Message)

MyBase.WndProc(m)
Dim broadcastHeader As DEV_BROADCAST_HDR

Select Case m.Msg

'Look for a WM_DEVICECHANGE message.
Case WM_DEVICECHANGE

lstResults.Items.Add("WM_DEVICECHANGE")

If (m.WParam.ToInt32 = DBT_DEVICEARRIVAL) Then
lstResults.Items.Add("DBT_DEVICEARRIVAL")

'LParam is a pointer to a structure that begins with a
DEV_BROADCAST_HDR structure.

broadcastHeader = _
CType(m.GetLParam(broadcastHeader.GetType),
DEV_BROADCAST_HDR)

'Is it a device interface?
If (broadcastHeader.dbch_devicetype =
DBT_DEVTYP_DEVICEINTERFACE) Then

'LParam is a pointer to a DEV_BROADCAST_DEVICEINTERFACE
structure.
broadcastDeviceInterface = _
CType(m.GetLParam(broadcastDeviceInterface.GetType),
DEV_BROADCAST_DEVICEINTERFACE)

lstResults.Items.Add("size = " &
CStr(broadcastDeviceInterface.dbcc_size))

The dbcc_size parameter returns 194, but I've been unsuccessful at
retrieving broadcastDeviceInterface.dbcc_name. I've also tried
declaring dbcc_name in DEV_BROADCAST_DEVICEINTERFACE as:

<MarshalAs(UnmanagedType.LPTStr)> Dim dbcc_name As String
and:
Dim dbcc_name As String
and:
Dim dbcc_name as IntPtr
and using Marshal.PtrToStringAuto

Any suggestions welcome.

Jan Axelson
www.Lvr.com
 
P

Peter Huang

Hi Jan,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you do not know how to declare the
dbcc_name to return the device name from the LParam in the WinProc.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I am researching the problem, and I will update you with new information
ASAP.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

jan axelson

From your description, I understand that you do not know how to declare
the dbcc_name to return the device name from the LParam in the WinProc.
Have I fully understood you?

Yes, I'm trying to retrieve the dbcc_name string.

Thanks!

Jan Axelson
www.Lvr.com
 
P

Peter Huang

Hi Jan,

Thanks for posting in the community.

Based on my research, since the dbcc_name is a variable length member. I
think you may need to declare it as a char array.
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=128)> _
Public dbcc_name() As Char

You may set the SizeConst long enough to get the string.


Here is my test sample ,you may have a try.
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports System.Text
Public Class Form1
Inherits System.Windows.Forms.Form

Public Class Win32
Public Const WM_DEVICECHANGE = &H219
Public Const DBT_DEVICEARRIVAL = &H8000
Public Const DBT_DEVICEREMOVECOMPLETE = &H8004
Public Const DEVICE_NOTIFY_WINDOW_HANDLE = 0
Public Const DEVICE_NOTIFY_SERVICE_HANDLE = 1
Public Const DBT_DEVTYP_DEVICEINTERFACE = 5
Public Shared GUID_IO_MEDIA_ARRIVAL As Guid = New
Guid("A5DCBF10-6530-11D2-901F-00C04FB951ED")

<StructLayout(LayoutKind.Sequential)> _
Public Class DEV_BROADCAST_DEVICEINTERFACE
Public dbcc_size As Integer
Public dbcc_devicetype As Integer
Public dbcc_reserved As Integer
Public dbcc_classguid As Guid
Public dbcc_name As Short
End Class
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Class DEV_BROADCAST_DEVICEINTERFACE1
Public dbcc_size As Integer
Public dbcc_devicetype As Integer
Public dbcc_reserved As Integer
<MarshalAs(UnmanagedType.ByValArray,
ArraySubType:=UnmanagedType.U1, SizeConst:=16)> _
Public dbcc_classguid() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=128)> _
Public dbcc_name() As Char
End Class
<StructLayout(LayoutKind.Sequential)> _
Public Class DEV_BROADCAST_HDR
Public dbcc_size As Integer
Public dbcc_devicetype As Integer
Public dbcc_reserved As Integer
End Class

<DllImport("user32.DLL", SetLastError:=True)> _
Public Shared Function _
RegisterDeviceNotification(ByVal IntPtr As IntPtr, ByVal
NotificationFilter As IntPtr, ByVal Flags As Int32) As IntPtr
End Function

<DllImport("kernel32.DLL")> _
Public Shared Function _
GetLastError() As Integer
End Function
End Class

Public Sub New()
MyBase.New()
InitializeComponent()
RegisterHidNotification()
End Sub

Public Sub RegisterHidNotification()
Dim dbi As Win32.DEV_BROADCAST_DEVICEINTERFACE = New
Win32.DEV_BROADCAST_DEVICEINTERFACE
Dim size As Integer
size = Marshal.SizeOf(dbi)
Dim gd As Guid
' MsgBox(Marshal.SizeOf(gd))
' MsgBox(Marshal.SizeOf(New
Win32.DEV_BROADCAST_DEVICEINTERFACE1))
dbi.dbcc_size = size
dbi.dbcc_devicetype = Win32.DBT_DEVTYP_DEVICEINTERFACE
dbi.dbcc_reserved = 0
dbi.dbcc_classguid = Win32.GUID_IO_MEDIA_ARRIVAL
Dim Buffer As IntPtr
Buffer = Marshal.AllocHGlobal(size)
Marshal.StructureToPtr(dbi, Buffer, True)
Dim r As IntPtr
r = Win32.RegisterDeviceNotification(Handle, Buffer,
Win32.DEVICE_NOTIFY_WINDOW_HANDLE)
Marshal.PtrToStructure(Buffer, dbi)
If r.ToInt32 = IntPtr.Zero.ToInt32 Then
MessageBox.Show(Win32.GetLastError().ToString())
End If
End Sub

Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = Win32.WM_DEVICECHANGE Then
OnDeviceChange(m)
End If
MyBase.WndProc(m)
End Sub

Private Sub OnDeviceChange(ByVal msg As Message)
Dim wParam As Integer
wParam = msg.WParam.ToInt32()
If wParam = Win32.DBT_DEVICEARRIVAL Then
Dim o As New Win32.DEV_BROADCAST_HDR
Dim b As New Win32.DEV_BROADCAST_DEVICEINTERFACE1
Dim gd As Guid
Marshal.PtrToStructure(msg.LParam, o)
If (o.dbcc_devicetype = Win32.DBT_DEVTYP_DEVICEINTERFACE) Then
Dim strsize As Integer = (o.dbcc_size - 28) / 2
ReDim b.dbcc_name(strsize)
Marshal.PtrToStructure(msg.LParam, b)
MsgBox(New Guid(b.dbcc_classguid).ToString)
Dim str As New String(b.dbcc_name, 0, strsize)
MsgBox(str)
End If
MessageBox.Show("Arrival")
ElseIf wParam = Win32.DBT_DEVICEREMOVECOMPLETE Then
MessageBox.Show("Remove")
End If
End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container
Me.Text = "Form1"
Dim t As New Guid("d07433c0-a98e-11d2-917a-00a0c9068ff3")
End Sub
End Class

If you have any concern on this issue please post here.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

jan Axelson

Thanks for responding. I've made some progress but still don't have
the dbcc_name string in a String variable.

strsize = 83, which equals the number of characters in the device name
and is thus correct.

But this:

Dim str As New String(b.dbcc_name, 0, strsize)

results in str = "/", only the first character.

This code:

Dim count As Integer
For count = 0 To (strsize - 1) * 2
lstResults.Items.Add(o.dbcc_name(count))
Next count

displays all of the characters in the device name, with each character
followed by an extra null character. So the string is there, but in an
incorrect format.

dbcc_name is declared as a Char array, as in your example.

How can I get the complete and correct string into str?

***

A couple of other things:

At this line:

Marshal.PtrToStructure(msg.LParam, o)

I got the exception:

An unhandled exception of type 'System.ArgumentException' occurred
in mscorlib.dll

Additional information: The structure must not be a value class.

I got rid of the exception by turning Option Strict Off and using:

o = Marshal.PtrToStructure(m.LParam, GetType(DEV_BROADCAST_HDR))

Same thing for Marshal.PtrToStructure(msg.LParam, b)

Is there a way to accomplish this with Option Strict On?

***

And the dbcc in your example:

Dim strsize As Integer = (o.dbcc_size - 28) / 2

should be dbch:

Dim strsize As Integer = (o.dbch_size - 28) / 2

***

Jan Axelson
www.Lvr.com
 
P

Peter Huang

Hi Jan,

Thanks for your quickly reply!

Since the code runs well on my machine, can you try to create a new winform
application and copy and paste my code for test, to see if it has any
difference with yours.

Comments in lines.

If you have any concern on this issue,please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: jan Axelson <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
Subject: Re: Retrieving dbcc_name string from a
DEV_BROADCAST_DEVICEINTERFACE structure
Date: Tue, 10 Feb 2004 20:35:01 -0600
Organization: Posted via Supernews, http://www.supernews.com
Message-ID: <[email protected]>
References: <[email protected]>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Complaints-To: (e-mail address removed)
Lines: 228
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.su
l.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn
-xit-03!sn-xit-04!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-
for-mail
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:180311
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Thanks for responding. I've made some progress but still don't have
the dbcc_name string in a String variable.

strsize = 83, which equals the number of characters in the device name
and is thus correct.

But this:

Dim str As New String(b.dbcc_name, 0, strsize)

results in str = "/", only the first character.

This code:

Dim count As Integer
For count = 0 To (strsize - 1) * 2
lstResults.Items.Add(o.dbcc_name(count))
Next count

displays all of the characters in the device name, with each character
followed by an extra null character. So the string is there, but in an
incorrect format.

dbcc_name is declared as a Char array, as in your example.

How can I get the complete and correct string into str?

***

I think the return string is correct, since the return string is encoded in
Unicode, in which way every char will occupy two byte, i.e. a english
character will be encoded as "5c 00" which means '\'. For a variable length
string in a structure, I think we may need to declare it as char array to
do the marshal ourself.
A couple of other things:

At this line:

Marshal.PtrToStructure(msg.LParam, o)

I got the exception:

An unhandled exception of type 'System.ArgumentException' occurred
in mscorlib.dll

Additional information: The structure must not be a value class.

I got rid of the exception by turning Option Strict Off and using:

o = Marshal.PtrToStructure(m.LParam, GetType(DEV_BROADCAST_HDR))

Same thing for Marshal.PtrToStructure(msg.LParam, b)

Is there a way to accomplish this with Option Strict On?

***

It is somewhat strange that the
Marshal.PtrToStructure(msg.LParam, o)
doesn't work for you.
And the dbcc in your example:

Dim strsize As Integer = (o.dbcc_size - 28) / 2

should be dbch:

Dim strsize As Integer = (o.dbch_size - 28) / 2

***

The o is a DEV_BROADCAST_HDR instance.
I defined it as below.
Public Class DEV_BROADCAST_HDR
Public dbcc_size As Integer
Public dbcc_devicetype As Integer
Public dbcc_reserved As Integer
End Class

so I use the o.dbcc_size, I am sorry if any confusion.
 
J

jan Axelson

It's working now. I missed the:

CharSet:=CharSet.Unicode

in the declaration for:

Public Class DEV_BROADCAST_DEVICEINTERFACE1

Thanks a million.

Jan Axelson
www.Lvr.com
 
Joined
Jul 27, 2007
Messages
1
Reaction score
0
Hello Peter and Juan.

Well, today, I am a bit like you, I cannot read the dbvv_name element of the
DEV_BROADCAST_DEVICEINTERFACE structure. I can get teh GUID ok and after checking it in the registry, it is correct, but when it comes to display the string name, I get nothing. my string length is 0.

I am using VB6 and after about 2 weeks of research on the web, the code below is as far as I got. If one of you could have a look and tel me wwhat am I doing wrong, I'd be very grateful to you.

This is my code for the form

Private Declare Function RegisterDeviceNotification Lib "User32.dll" Alias "RegisterDeviceNotificationA" (ByVal hRecipient As Long, ByRef NotificationFilter As Any, ByVal Flags As Long) As Long
Private Declare Function UnregisterDeviceNotification Lib "User32.dll" (ByVal Handle As Long) As Long
Private Type Guid
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Type DEV_BROADCAST_DEVICEINTERFACE
dbcc_size As Long
dbcc_devicetype As Long
dbcc_reserved As Long
dbcc_classguid As Guid
dbcc_name As Long
End Type
Private hDevNotify As Long
Private Const DEVICE_NOTIFY_WINDOW_HANDLE As Long = &H0
Private Const DBT_DEVTYP_DEVICEINTERFACE As Long = &H5 ' Device interface class
Private Const DEVICE_NOTIFY_ALL_INTERFACE_CLASSES As Long = &H4
Private Sub Form_Load()
Dim NotificationFilter As DEV_BROADCAST_DEVICEINTERFACE
With NotificationFilter
.dbcc_size = Len(NotificationFilter)
.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE
End With
Call SubClass(Me.hWnd)
hDevNotify = RegisterDeviceNotification(Me.hWnd, NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE Or DEVICE_NOTIFY_ALL_INTERFACE_CLASSES)
End Sub
Private Sub Form_Unload(ByRef Cancel As Integer)
Call UnregisterDeviceNotification(hDevNotify)
Call UnSubClass
End Sub





...and the code for the module


Private Declare Function SetWindowLong Lib "User32.dll" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "User32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function StringFromGUID2 Lib "OLE32.dll" (ByRef rGUID As Any, ByVal lpSz As String, ByVal cchMax As Long) As Long
Private Declare Function lstrcpyA Lib "Kernel32.dll" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long
Private Declare Function lstrlenA Lib "Kernel32.dll" (ByVal lpString As Long) As Long
Private Declare Function GetDriveType Lib "Kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Sub RtlMoveMemory Lib "Kernel32.dll" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
Private Declare Sub GetDWord Lib "MSVBVM60.dll" Alias "GetMem4" (ByRef inSrc As Any, ByRef inDst As Long)
Private Declare Sub GetWord Lib "MSVBVM60.dll" Alias "GetMem2" (ByRef inSrc As Any, ByRef inDst As Integer)

Private Type Guid
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Type DEV_BROADCAST_HDR
dbch_size As Long
dbch_devicetype As Long
dbch_reserved As Long
End Type
Dim OldProc As Long
Dim WndHnd As Long
Private Const GWL_WNDPROC As Long = (-4)
Private Const WM_DEVICECHANGE As Long = &H219
Private Const DBT_DEVNODES_CHANGED As Long = &H7
Private Const DBT_DEVICEARRIVAL As Long = &H8000&
Private Const DBT_DEVICEREMOVECOMPLETE As Long = &H8004&

Private Const DBT_DEVTYP_OEM As Long = &H0
Private Const DBT_DEVTYP_DEVNODE As Long = &H1
Private Const DBT_DEVTYP_VOLUME As Long = &H2 ' Logical volume
Private Const DBT_DEVTYP_PORT As Long = &H3 ' USB I/O Port
Private Const DBT_DEVTYP_NET As Long = &H4
Private Const DBT_DEVTYP_DEVICEINTERFACE As Long = &H5 ' Device interface class

Private Const DBTF_MEDIA As Long = &H1 ' Media comings and goings
Private Const DBTF_NET As Long = &H2 ' Network volume
Private Const DRIVE_NO_ROOT_DIR As Long = 1
Private Const DRIVE_REMOVABLE As Long = 2
Private Const DRIVE_FIXED As Long = 3
Private Const DRIVE_REMOTE As Long = 4
Private Const DRIVE_CDROM As Long = 5
Private Const DRIVE_RAMDISK As Long = 6

Public Sub SubClass(ByVal inWnd As Long)
If (WndHnd) Then Call UnSubClass
OldProc = SetWindowLong(inWnd, GWL_WNDPROC, AddressOf WndProc)
WndHnd = inWnd
End Sub

Public Sub UnSubClass()
If (WndHnd = 0) Then Exit Sub
Call SetWindowLong(WndHnd, GWL_WNDPROC, OldProc)
WndHnd = 0
OldProc = 0
End Sub

Private Function WndProc(ByVal hWnd As Long, _
ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim DevBroadcastHeader As DEV_BROADCAST_HDR
Dim UnitMask As Long, Flags As Integer
Dim DeviceGUID As Guid
Dim DeviceNamePtr As Long
Dim DriveLetters As String
Dim LoopDrives As Long
Dim TempStr As String


If (uMsg = WM_DEVICECHANGE) Then
Select Case wParam
Case DBT_DEVICEARRIVAL
If (lParam) Then ' Read generic DEV_BROADCAST_HDR structure
Call RtlMoveMemory(DevBroadcastHeader, ByVal lParam, Len(DevBroadcastHeader))
'MsgBox "Device arrived"
If (DevBroadcastHeader.dbch_devicetype = DBT_DEVTYP_VOLUME) Then
' Read end of DEV_BROADCAST_VOLUME structure
Call GetDWord(ByVal (lParam + Len(DevBroadcastHeader)), UnitMask)
Call GetWord(ByVal (lParam + Len(DevBroadcastHeader) + 4), Flags)
DriveLetters = UnitMaskToString(UnitMask)

For LoopDrives = 1 To Len(DriveLetters) ' Print a message for each drive
Form1.Text1.Text = Form1.Text1.Text + vbCrLf + vbCrLf + " 1 - " + "Drive " & Mid$(DriveLetters, LoopDrives, 1) & " " & _
IIf(wParam = DBT_DEVICEARRIVAL, "Inserted", "Ejected") & " (" & _
DriveTypeToString(GetDriveType(Mid$(DriveLetters, LoopDrives, 1) & ":\")) & ")"
Next LoopDrives
ElseIf (DevBroadcastHeader.dbch_devicetype = DBT_DEVTYP_DEVICEINTERFACE) Then
' Read end of DEV_BROADCAST_DEVICEINTERFACE structure
Call RtlMoveMemory(DeviceGUID, ByVal (lParam + Len(DevBroadcastHeader)), Len(DeviceGUID))
Call GetDWord(ByVal (lParam + Len(DevBroadcastHeader) + Len(DeviceGUID)), DeviceNamePtr)

'The VID and the PID should be displayed with "name", but they are not.
Form1.Text1.Text = Form1.Text1.Text + vbCrLf + vbCrLf + " 2 - " + _
"Device GUID: " & GUIDToString(DeviceGUID) & _
", name: """ & CopyStringA(DeviceNamePtr) & """" + vbCrLf + _
"DeviceNamePtr: " + Hex(DeviceNamePtr)
End If
End If
Case DBT_DEVICEREMOVECOMPLETE
'MsgBox "Device removed"

Case DBT_DEVNODES_CHANGED
'MsgBox "Device added or removed"
End Select
End If
WndProc = CallWindowProc(OldProc, hWnd, uMsg, wParam, lParam)
End Function

Private Function UnitMaskToString(ByVal inUnitMask As Long) As String
Dim LoopBits As Long
For LoopBits = 0 To 30
If (inUnitMask And (2 ^ LoopBits)) Then _
UnitMaskToString = UnitMaskToString & Chr$(Asc("A") + LoopBits)
Next LoopBits
End Function

Private Function GUIDToString(ByRef inGUID As Guid) As String
Dim RetBuf As String, GUILen As Long
Const BufLen As Long = 80
RetBuf = Space$(BufLen)
GUILen = StringFromGUID2(inGUID, RetBuf, BufLen)
If (GUILen) Then GUIDToString = StrConv(Left$(RetBuf, (GUILen - 1) * 2), vbFromUnicode)
End Function

Public Function CopyStringA(ByVal inPtr As Long) As String
Dim BufLen As Long
BufLen = lstrlenA(inPtr)
If (BufLen > 0) Then
CopyStringA = Space$(BufLen)
Call lstrcpyA(CopyStringA, inPtr)
End If
End Function

Private Function DriveTypeToString(ByVal inDriveType As Long) As String
Select Case inDriveType
Case DRIVE_NO_ROOT_DIR: DriveTypeToString = "No root directory" '??
Case DRIVE_REMOVABLE: DriveTypeToString = "Removable"
Case DRIVE_FIXED: DriveTypeToString = "Fixed"
Case DRIVE_REMOTE: DriveTypeToString = "Remote"
Case DRIVE_CDROM: DriveTypeToString = "CD-ROM"
Case DRIVE_RAMDISK: DriveTypeToString = "RAM disk"
Case Else: DriveTypeToString = "[ Unknown ]"
End Select
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top