R
Rob
I wanted to pass ByVal a Me.Handle() to a CStyle DLL.
The code for the DLL is as follows:
void __stdcall WriteWindowHandle(HWND wHandle)
{
DATASTRUCT ds;
DWORD dwBytesWritten;
ds.wndHandle = wHandle;
m_pMem->Lock();
BOOL bSuccess = m_pMem->Write (
&ds, // Destination for data
sizeof(ds), // Number of bytes to write
&dwBytesWritten, // Buffer for count of bytes uploaded to shared memory
0 // Offset into shared memory buffer
);
m_pMem->Unlock();
return;
}
Using Visual Basic 6 a Long parameter is easily marshalled to HWND wHandle.
However using the VB.NET code written below I cannot find a way to marshal
Me.Handle() into the above HWND wHandle parameter. The code does compile,
but will not execute.
Public Class LibWrap
' Declare a managed prototype for the unmanaged function.
Declare Function WriteWindowHandle Lib _
"C:\Program Files\AmiBroker\Plugins\XLPlugin.dll" (ByVal i As Integer)
End Class 'LibWrap
' Blah Blah Blah
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
LibWrap.WriteWindowHandle(Me.Handle().ToInt32()) 'This line will not execute
'System.Runtime.InteropServices.MarshalDirectiveException' occurred in App5.exe
End Sub
The question is how can I marshal Me.Handle() into HWND wHandle.
The code for the DLL is as follows:
void __stdcall WriteWindowHandle(HWND wHandle)
{
DATASTRUCT ds;
DWORD dwBytesWritten;
ds.wndHandle = wHandle;
m_pMem->Lock();
BOOL bSuccess = m_pMem->Write (
&ds, // Destination for data
sizeof(ds), // Number of bytes to write
&dwBytesWritten, // Buffer for count of bytes uploaded to shared memory
0 // Offset into shared memory buffer
);
m_pMem->Unlock();
return;
}
Using Visual Basic 6 a Long parameter is easily marshalled to HWND wHandle.
However using the VB.NET code written below I cannot find a way to marshal
Me.Handle() into the above HWND wHandle parameter. The code does compile,
but will not execute.
Public Class LibWrap
' Declare a managed prototype for the unmanaged function.
Declare Function WriteWindowHandle Lib _
"C:\Program Files\AmiBroker\Plugins\XLPlugin.dll" (ByVal i As Integer)
End Class 'LibWrap
' Blah Blah Blah
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
LibWrap.WriteWindowHandle(Me.Handle().ToInt32()) 'This line will not execute
'System.Runtime.InteropServices.MarshalDirectiveException' occurred in App5.exe
End Sub
The question is how can I marshal Me.Handle() into HWND wHandle.