首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

Delphi7下动态调用API的有关问题

2012-03-17 
Delphi7下动态调用API的问题我在Delphi7中编写有以下代码:procedureTForm1.Button1Click(Sender:TObject)

Delphi7下动态调用API的问题
我在Delphi7中编写有以下代码:

procedure   TForm1.Button1Click(Sender:   TObject);
var
    hMod:Thandle;
    MyText:function(DC:   HDC;   X,   Y:   Integer;   Str:   PChar;   Count:   Integer):   BOOL;   stdcall;
begin
    hMod:=LoadLibrary( 'C:\Windows\System32\GDI32.dll ');
    try
    if   hMod <=0   then
        MessageBox(0, '装载DLL失败! ', '提示 ',MB_OK   or   MB_ICONERROR)
    else
        begin
            @MyText:=GetProcAddress(hMod, 'TextOut ');
            if   (@MyText <> nil)   then
                MyText(Self.Canvas.Handle,600,300, 'HJXLJ ',5)
            else
                MessageBox(0, '取函数地址失败! ', '提示 ',MB_OK   or   MB_ICONERROR);
        end;
    finally
    FreeLibrary(hMod);
    end;
end;

但在运行时总是显示 "取函数地址失败! "。不知是何缘故,请大家给予指点。另外,我使用的操作系统为Windows   XP   Home   Edition(Service   Pack2)。

[解决办法]
win32中没有TextOut,只有TextOutA和TextOutW。
TextOut只存在于win16中。

热点排行