[Mono-list] Win32 API problems

Adiraj, Sarat sarat.adiraj@verizon.com
Thu, 13 Jun 2002 14:27:02 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C21310.4B8495E0
Content-Type: text/plain;
	charset="ISO-8859-1"

mono causes a stack overflow when i try to use pinvoke for calling a win32
function.The code i used is as follows:

namespace APIExample
{
using System;
// Must refernce this library to use PI nvoke types
using System.Runtime.InteropServices;
public class PinvokeClient
{
	
[DllImport("user32")]
public static extern int MessageBoxA(int hWnd, 
String pText ,
String pCaption ,
int uType);
public static int Main(string[] args)
{
int res;
String pText = "HELLO World!!";
String pCaption = "Example by Sarat";
res = MessageBoxA(0,pText,pCaption,0);
Console.WriteLine(res);	
return 0;
}
}
}

please advice if this is a bug with mono or if it is something wrong with my
code.

-- Sarat



------_=_NextPart_001_01C21310.4B8495E0
Content-Type: text/html;
	charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DISO-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>Win32 API problems</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2 FACE=3D"Arial">mono causes a stack overflow when i =
try to use pinvoke for calling a win32 function.The code i used is as =
follows:</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">namespace APIExample</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">{</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">using System;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">// Must refernce this library to use =
PI nvoke types</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">using =
System.Runtime.InteropServices;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">public class PinvokeClient</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR><FONT SIZE=3D2 =
FACE=3D"Arial">[DllImport(&quot;user32&quot;)]</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">public static extern int =
MessageBoxA(int hWnd, </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">String pText ,</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">String pCaption ,</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">int uType);</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">public static int Main(string[] =
args)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">{</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">int res;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">String pText =3D &quot;HELLO =
World!!&quot;;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">String pCaption =3D &quot;Example by =
Sarat&quot;;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">res =3D =
MessageBoxA(0,pText,pCaption,0);</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Console.WriteLine(res); </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">return 0;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">}</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">}</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">}</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">please advice if this is a bug with =
mono or if it is something wrong with my code.</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">-- Sarat</FONT>
</P>
<BR>

</BODY>
</HTML>
------_=_NextPart_001_01C21310.4B8495E0--