2010-04-29 46 views
1

我想打電話給在德爾福棱鏡窗口的SendMessage函數的方法,我已經聲明的類如下:德爾福棱鏡越來越未知的標識符「的DllImport」錯誤

type 
    MyUtils = public static class 
    private 
    [DllImport("user32.dll", CharSet := CharSet.Auto)] 
    method SendMessage(hWnd:IntPtr; Msg:UInt32; wParam:IntPtr; lParam:IntPtr):IntPtr; external; 
    protected 
    public 
    end; 

當我試圖編譯,我得到的錯誤Unknown identifier "DllImport"

我以此爲例,How to call function CreateProcess in Delphi Prism?和語法看起來一樣。有沒有需要啓用的設置,還是我有語法錯誤?

回答

3

確保您導入(使用)System.Runtime.InteropServices。這就是DllImport屬性的定義。