S
Schorschi
I am trying to mimic the following (which works) but Use the stock
GetManifestResourceStream route.
For example
Public Declare Unicode Function LoadCursorFromFile Lib "USER32.DLL"
Alias "LoadCursorFromFileW" (ByVal thePath As String) As IntPtr
Dim theCursor As Cursor
theCursor = New Cursor(LoadCursorFromFile(thePath))
Me.Cursor = theCursor
This works!
However, the following does not...
Dim theType As Type
Dim theStream As IO.Stream
Dim thePointer As IntPtr
Dim theBytes() As Byte
Dim theHandle As GCHandle
'
theType = GetCurrentMethod. _
ReflectedType
theStream =
[Assembly].GetAssembly(theType).GetManifestResourceStream _
(theType.Namespace & "." & thePath)
ReDim theBytes(CInt(theStream.Length + 4 - 1))
theStream.Read(theBytes, 0, theBytes.Length)
theHandle = GCHandle.Alloc(theBytes,
GCHandleType.Pinned)
thePointer = theHandle.AddrOfPinnedObject
theCursor = New Cursor(thePointer)
Me.Cursor = theCursor
I get no errors, in fact, theStream is valid, ie. thePath is the path
to my cursor resource. 'theBytes' array has what I believe is the
binary of the stream. And the theCursor.Handle = thePointer (ie. the
..NET Cursor Class initializes pointing to the IntPtr.
Help!
GetManifestResourceStream route.
For example
Public Declare Unicode Function LoadCursorFromFile Lib "USER32.DLL"
Alias "LoadCursorFromFileW" (ByVal thePath As String) As IntPtr
Dim theCursor As Cursor
theCursor = New Cursor(LoadCursorFromFile(thePath))
Me.Cursor = theCursor
This works!
However, the following does not...
Dim theType As Type
Dim theStream As IO.Stream
Dim thePointer As IntPtr
Dim theBytes() As Byte
Dim theHandle As GCHandle
'
theType = GetCurrentMethod. _
ReflectedType
theStream =
[Assembly].GetAssembly(theType).GetManifestResourceStream _
(theType.Namespace & "." & thePath)
ReDim theBytes(CInt(theStream.Length + 4 - 1))
theStream.Read(theBytes, 0, theBytes.Length)
theHandle = GCHandle.Alloc(theBytes,
GCHandleType.Pinned)
thePointer = theHandle.AddrOfPinnedObject
theCursor = New Cursor(thePointer)
Me.Cursor = theCursor
I get no errors, in fact, theStream is valid, ie. thePath is the path
to my cursor resource. 'theBytes' array has what I believe is the
binary of the stream. And the theCursor.Handle = thePointer (ie. the
..NET Cursor Class initializes pointing to the IntPtr.
Help!