What is the equivalent VB syntax for this c# code?

  • Thread starter John Heitmuller.
  • Start date

J

John Heitmuller.

private const int RF_TESTMESSAGE = 0xA123;

[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int SendMessage(IntPtr hwnd,
[MarshalAs(UnmanagedType.U4)] int Msg, uint wParam, ulong lParam);

I'm trying to send a Windows message from a VB.NET 2005 app. I found
this example in C# that works fine, but I cannot figure out the VB
sysntax.

Thanks,
John
 
Ad

Advertisements

K

kimiraikkonen

private const int RF_TESTMESSAGE = 0xA123;

[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int SendMessage(IntPtr hwnd,
[MarshalAs(UnmanagedType.U4)] int Msg, uint wParam, ulong lParam);

I'm trying to send a Windows message from a VB.NET 2005 app.  I found
this example in C# that works fine, but I cannot figure out the VB
sysntax.

Thanks,
John
Try this (untested):

Private Const RF_TESTMESSAGE As Integer = 41251

<DllImport("user32.dll", CharSet := CharSet.Auto, SetLastError :=
True)> _
Public Shared Function SendMessage(ByVal hwnd As IntPtr,
<MarshalAs(UnmanagedType.U4)> _
ByVal Msg As Integer, ByVal wParam As UInteger, ByVal lParam As ULong)
As Integer
End Function
 
H

Herfried K. Wagner [MVP]

John Heitmuller. said:
private const int RF_TESTMESSAGE = 0xA123;

[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int SendMessage(IntPtr hwnd,
[MarshalAs(UnmanagedType.U4)] int Msg, uint wParam, ulong lParam);
Are you sure the parameter types for the 'wParam' and 'lParam' parameters
are correct? Note that they are 'IntPtr's, which means that they are 32-bit
types on 32-bit Windows versions and 64-bit types on 64-bit versions.
 
D

David Anton

(Instant VB)
Private Const RF_TESTMESSAGE As Integer = &HA123

<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function SendMessage(ByVal hwnd As IntPtr,
<MarshalAs(UnmanagedType.U4)> ByVal Msg As Integer, ByVal wParam As UInteger,
ByVal lParam As ULong) As Integer
End Function
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
Java to C#
Java to VB
Instant C#: convert VB to C#
Instant VB: convert C# to VB
Instant C++: VB, C#, or Java to C++/CLI
 
F

Family Tree Mike

John Heitmuller. said:
private const int RF_TESTMESSAGE = 0xA123;

[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int SendMessage(IntPtr hwnd,
[MarshalAs(UnmanagedType.U4)] int Msg, uint wParam, ulong lParam);

I'm trying to send a Windows message from a VB.NET 2005 app. I found
this example in C# that works fine, but I cannot figure out the VB
sysntax.

Thanks,
John
http://www.pinvoke.net/ lists the following definition for SendMessage in
VB.net:

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Function SendMessage( _
ByVal hWnd As HandleRef, _
ByVal Msg As UInteger, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
End Function
 
Ad

Advertisements

J

John Heitmuller.

Thanks to everybody. With your help I got it working.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top