You write the following code segment to call a function from the Win32 Application Programming Interface (API) by using platform invoke.
Dim PersonName as String = "N?el"Dim Msg as String = "Welcome " + PersonName + " to club
''!"Dim r As Boolean= User32API.MessageBox(0, Msg, PersonName, 0) You need to define a
method prototype that can best marshal the string data. Which code segment should you use?
A. <DllImport("user32", CharSet:=CharSet.Ansi)> _Public Function MessageBox(ByVal
hWnd As Int32, _ByVal text As String, ByVal caption As String, _ByVal t As UInt32)
As BooleanEnd Function
B. <DllImport("user32", EntryPoint:="MessageBoxA", _CharSet:=CharSet.Ansi)>
_Public Function MessageBox(ByVal hWnd As Int32,
_<MarshalAs(UnmanagedType.LPWStr)> ByVal text As String,
_<MarshalAs(UnmanagedType.LPWStr)> ByVal caption As String, _ByVal t As
UInt32) As BooleanEnd Function
C. <DllImport("user32", CharSet:=CharSet.Unicode)> _Public Function
MessageBox(ByVal hWnd As Int32, _ByVal text As String, ByVal caption As String,
_ByVal t As UInt32) As BooleanEnd Function
D. DllImport("user32", EntryPoint:="MessageBoxA", _CharSet:=CharSet.Unicode)>
_Public Function MessageBox(ByVal hWnd As Int32,
_<MarshalAs(UnmanagedType.LPWStr)> ByVal text As String,
_<MarshalAs(UnmanagedType.LPWStr)> ByVal caption As String, _ByVal t As
UInt32) As BooleanEnd Function
Answer: C
Dim PersonName as String = "N?el"Dim Msg as String = "Welcome " + PersonName + " to club
''!"Dim r As Boolean= User32API.MessageBox(0, Msg, PersonName, 0) You need to define a
method prototype that can best marshal the string data. Which code segment should you use?
A. <DllImport("user32", CharSet:=CharSet.Ansi)> _Public Function MessageBox(ByVal
hWnd As Int32, _ByVal text As String, ByVal caption As String, _ByVal t As UInt32)
As BooleanEnd Function
B. <DllImport("user32", EntryPoint:="MessageBoxA", _CharSet:=CharSet.Ansi)>
_Public Function MessageBox(ByVal hWnd As Int32,
_<MarshalAs(UnmanagedType.LPWStr)> ByVal text As String,
_<MarshalAs(UnmanagedType.LPWStr)> ByVal caption As String, _ByVal t As
UInt32) As BooleanEnd Function
C. <DllImport("user32", CharSet:=CharSet.Unicode)> _Public Function
MessageBox(ByVal hWnd As Int32, _ByVal text As String, ByVal caption As String,
_ByVal t As UInt32) As BooleanEnd Function
D. DllImport("user32", EntryPoint:="MessageBoxA", _CharSet:=CharSet.Unicode)>
_Public Function MessageBox(ByVal hWnd As Int32,
_<MarshalAs(UnmanagedType.LPWStr)> ByVal text As String,
_<MarshalAs(UnmanagedType.LPWStr)> ByVal caption As String, _ByVal t As
UInt32) As BooleanEnd Function
Answer: C
No comments:
Post a Comment