Click here to Skip to main content
12,950,272 members (65,840 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi,
how can I convert this to c#.

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

Thanks a lot
Almir
Posted 20-Nov-12 2:41am
AlmirM666
Comments
Lakhan Aanjana 20-Nov-12 11:21am
   
try this

http://www.developerfusion.com/tools/convert/vb-to-csharp/?batchId=17e4fb38-1c4e-422c-9d7a-0746a44b915a
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
AlmirM 20-Nov-12 8:50am
   
This translator does not return anything after I copy/paste my line of code...
Did you try? If yes can you please then let me about the results
Thanks
Earloc 20-Nov-12 8:53am
   
the output gives

[DllImport("user32.dll", EntryPoint="SendMessageA")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

as this signature indicates a platform invokation of a win32-dll, take a look at pinvoke.net[^]
  Permalink  
v2
Comments
AlmirM 20-Nov-12 9:03am
   
When I copy/paste

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

Then DllImport is underlined saying that I missing type or reference. What shoul I referernce to in order to make this working
Please help
Earloc 20-Nov-12 9:32am
   
DllImport (System.Runtime.InteropServices.DllImportAttribute) is defined in mscorlib.dll. make sure you add a using directive to its namespace:

using System.Runtime.InteropService;
refer to http://msdn.microsoft.com/en-US/library/system.runtime.interopservices.dllimportattribute.aspx

and remember: MSDN is your friend :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Use this online converter to convert your code
Convert VB.NET to C#[^]

You might also find the below article helpful
.NET Code Conversion - Convert your code[^]
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,829
CHill60 3,460
Maciej Los 2,953
Jochen Arndt 1,975
ppolymorphe 1,820


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100