Hi 

InteropServices heissen System.Runtime.InteropServices und nicht
System.Interop.(Die Bezeichnung
stammt glaube ich aus Beta 1). Deswegen sagt der Compiler auch: "are you
missing a using directive or an assembly reference" ;)

Es geht zum Beispiel so :

using System;
using System.Runtime.InteropServices;
class HelloWorld
{
        [DllImport("User32.dll")]
        public static extern int MessageBoxW( 
        int h, 
        IntPtr m, 
        IntPtr c, 
        int type);
        
        public static int Main() 
        {
        return MessageBoxW(0, Marshal.StringToHGlobalUni("Hello World!"),
Marshal.StringToHGlobalUni("Caption"), 0);
        }
}


Noch Ein Tipp, Schau dir die System.Windows.Forms ein bisschen genauer
an....

Bye
Igor


-----Urspr�ngliche Nachricht-----
Von: anfaenger [mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 13. November 2001 16:00
An: C Sharp
Betreff: [dotnetdecsharp] hello world programm


Hallo,

ich m�chte dieses einfache Programm 

using System.Runtime.InteropServices;

class HelloWorld {
     [DllImport("user32.dll")]
     public static extern int MessageBoxA(int h, string m, string c, int
type);

    public static int Main() {
       return MessageBoxA(0, "Hello World!", "CRL Interop Services", 0);
    }
}

so �ndern, dass statt der Win32 API Funktion "MessageBoxA" die Funktion
"MessageBoxW" verwendet wird und der Output lesbar ist.
Hinweis: MessageBoxA verwendet f�r die beiden String Parameter m und c den
Standardtyp LPTStr und MessageBoxW den zwei-Byte Unicode Typ LPWStr.

Meine Probleml�sung:

using System;
using System.Interop;

class HelloWorld
{
    [DllImport("User32.dll")]
    public static extern int MessageBoxW( 
        int h, 
        [marshal(UnmanagedType.LPWStr)] string m, 
        [marshal(UnmanagedType.LPWStr)] string c, 
        int type);

    public static int Main() 
    {
        return MessageBoxW(0, "Hello World!", "Caption", 0);
    }
}

Kann mir jemand sagen, was ich hier falsch mache? 

Bekomme folgende Compilerfehler:
hw.cs(2,14): error CS0234: The type or namespace name 'Interop' does not
exist
        in the class or namespace 'System' (are you missing an assembly
        reference?)
hw.cs(7,6): error CS0246: The type or namespace name 'DllImport' could not
be
        found (are you missing a using directive or an assembly reference?)

W�rde mich �ber Hilfe sehr freuen,

Vielen Dank im voraus,
Markus
| [dotnetdecsharp] als [EMAIL PROTECTED] subscribed |
http://www.dotnetgerman.com/archiv/dotnetdecsharp/ = Listenarchiv |
Listenregeln, sowie An- und Abmeldung zu dieser Liste: |
http://www.dotnetgerman.com/listen/dotnetdecsharp.asp 

| [dotnetdecsharp] als [email protected] subscribed
| http://www.dotnetgerman.com/archiv/dotnetdecsharp/ = Listenarchiv
| Listenregeln, sowie An- und Abmeldung zu dieser Liste:
| http://www.dotnetgerman.com/listen/dotnetdecsharp.asp

Antwort per Email an