|
-
Aug 12th, 2012, 10:50 AM
#1
Syntax Question (I think)
Hi,
Can you tell me please the meaning and purpose of " <MarshalAs(UnmanagedType.U4)> " in the following code?
Code:
Private Declare Function mixerOpen Lib "winmm.dll" _
(ByRef phmx As Integer, <MarshalAs(UnmanagedType.U4)> ByVal uMxId As Integer, ByVal _
dwCallback As Integer, ByVal dwInstance As Integer, ByVal fdwOpen As Integer) As Integer
In particular the purpose of anything between the 'Less than' and 'Greater than' characters.
Poppa.
Last edited by Poppa Mintin; Aug 12th, 2012 at 11:15 AM.
Reason: Spelling !
Along with the sunshine there has to be a little rain sometime.
-
Aug 12th, 2012, 02:44 PM
#2
Re: Syntax Question (I think)
Marshal Class
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks, and converting managed to unmanaged types, as well as other miscellaneous methods used when interacting with unmanaged code.
In other words it prevents functions outside the usual scope of the vb.net environment breaking stuff!
-
Aug 12th, 2012, 11:46 PM
#3
Re: Syntax Question (I think)
The chevrons are used to denote an attribute. There are many more attributes than just MarshalAs and they are used for many and varied purposes. For instance, the way you see properties displayed in the Properties window for a control is determined by several attributes. For instance, the Text property of a control is listed in the Appearance section of the Properties window, which is achieved by declaring the property like this:
vb.net Code:
<Category("Appearance")> Public Property Text() As String '... End Property
Attributes are metadata, i.e. they are not part of the type or member itself but they are information about the type or member. In your example, the attribute determines how that member is mapped to and from unmanaged code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|