Question: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", EntryPoint:="MessageBoxA", _
"A Composite Solution With Just One Click" - Certification Guaranteed 185 Microsoft 70-536 Exam 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 Boolean
End Function 

B 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 Boolean
End 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 Boolean
End Function 

D <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 Boolean
End Function 

+ Answer
+ Report
Total Preview: 775

Copyright © 2024. Powered by Intellect Software Ltd