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

Antwort per Email an