K
Katie
Hi,
Im converting some C# RAPI code to VB .NET. The C# version works. However,
the VB version returns E_INVALIDARG
Does anyone see the conversion problem? i noted the lines that may be the
problem.
I know there are libraries available for RAPI but i can't use them
Thanks
Katie
C#
version --------------------------------------------------------------------
-----
[StructLayout(LayoutKind.Sequential)]
internal struct RAPIINIT
{
public int cbSize;
public IntPtr heRapiInit;
public int hrRapiInit;
}
public boolean TryRapiConnect()
{
// non-blocking init rapi call
private IntPtr hInitEvent = IntPtr.Zero;
private int InitResult = 0;
private RAPIINIT ri;
private int retVal = 0;
ri = new RAPIINIT();
ri.cbSize = Marshal.SizeOf(ri);
ri.hrRapiInit = InitResult;
hInitEvent = CreateEvent(IntPtr.Zero, 0, 0, "RapiInitEvent");
ri.heRapiInit = hInitEvent;
retVal = CeRapiInitEx(ref ri);
}
VB
version --------------------------------------------------------------------
--
<StructLayout(LayoutKind.Sequential)> _
Public Structure RAPIINIT
Dim cbSize As Integer
Dim heRapiInit As Integer
Dim hrRapiInit As Integer
End Structure
public Function TryRapiConnect() As Boolean
'non-blocking init rapi call
Dim hInitEvent As Integer = 0
Dim InitResult As Integer = 0
Dim ri As RAPIINIT
Dim retVal as integer = 0
ri = New RAPIINIT
ri.cbSize = Marshal.SizeOf(ri)
ri.hrRapiInit = 0
hInitEvent = CreateEvent(0, 0, 0, "RapiInitEvent") '<<< maybe problem
here with first arg
ri.heRapiInit = hInitEvent
retVal = CeRapiInitEx(ri) '<<< maybe problem here with arg. C# version
uses (ref ri). what should it be in VB?
End Function
Im converting some C# RAPI code to VB .NET. The C# version works. However,
the VB version returns E_INVALIDARG
Does anyone see the conversion problem? i noted the lines that may be the
problem.
I know there are libraries available for RAPI but i can't use them
Thanks
Katie
C#
version --------------------------------------------------------------------
-----
[StructLayout(LayoutKind.Sequential)]
internal struct RAPIINIT
{
public int cbSize;
public IntPtr heRapiInit;
public int hrRapiInit;
}
public boolean TryRapiConnect()
{
// non-blocking init rapi call
private IntPtr hInitEvent = IntPtr.Zero;
private int InitResult = 0;
private RAPIINIT ri;
private int retVal = 0;
ri = new RAPIINIT();
ri.cbSize = Marshal.SizeOf(ri);
ri.hrRapiInit = InitResult;
hInitEvent = CreateEvent(IntPtr.Zero, 0, 0, "RapiInitEvent");
ri.heRapiInit = hInitEvent;
retVal = CeRapiInitEx(ref ri);
}
VB
version --------------------------------------------------------------------
--
<StructLayout(LayoutKind.Sequential)> _
Public Structure RAPIINIT
Dim cbSize As Integer
Dim heRapiInit As Integer
Dim hrRapiInit As Integer
End Structure
public Function TryRapiConnect() As Boolean
'non-blocking init rapi call
Dim hInitEvent As Integer = 0
Dim InitResult As Integer = 0
Dim ri As RAPIINIT
Dim retVal as integer = 0
ri = New RAPIINIT
ri.cbSize = Marshal.SizeOf(ri)
ri.hrRapiInit = 0
hInitEvent = CreateEvent(0, 0, 0, "RapiInitEvent") '<<< maybe problem
here with first arg
ri.heRapiInit = hInitEvent
retVal = CeRapiInitEx(ri) '<<< maybe problem here with arg. C# version
uses (ref ri). what should it be in VB?
End Function