Delphi版本:Version7.0(Build 4.453)操作系统版本:MS Windows XP Professional;Service Pack2测试例子代码:
procedure TForm1.Timer1Timer(Sender: TObject);
var pot: TPoint;
begin
pot := Mouse.CursorPos;
Label1.Caption := Inttostr(pot.X);
Label2.Caption := Inttostr(pot.Y);
end;屏保时弹出错误提示:A Call to an OS function failed;

解决方案 »

  1.   

    The ''A call to an OS function failed'' usually means that are you using 
    way too many windowed controls. In other words you are out of window 
    handles. Windows 9x is more prone too this.There are some limits when it comes to the number of window handles and 
    related stuff. If your form(s) contain alot of windowed controls you are 
    sure to run against this wall quickly.Run the resource monitor and start your application, you should see the 
    resource counter go down fast. The total amount of resources available 
    also depends on what other applications you might be running.The best thing to do would be to use a proper operating system. Another 
    would be to restructure your application to use less resources or to 
    release those that aren''t used.Regards,Christophe Geers
      

  2.   

    http://forums.devshed.com/delphi-programming-90/error-a-call-to-an-os-function-failed-185750.html
    有部分以下内容:
    screen savers --------------------------------------------------------------------------------I am a chinese boy . My English Is Poor , I find the problem is 
    screen savers . if i stop the screen savers , my application is run ok ,but run the screen savers , the problem is come in .
    i use cxgrid component.为什么又是chinese boy,难道在中国才会有这个情况……
      

  3.   

    回1楼:
    俺E文很菜,勉强看懂一点儿你发的内容,too many windowed controls没有,例子上就一个timer控件。
      

  4.   


    var
       cursorPos       : TPoint;begin
         GetCursorPos(cursorPos);
         cursorPos := ScreenToClient(cursorPos);试试?
      

  5.   

    i can hardly understand  - -
      

  6.   

    回4楼:
    直接调用GetCursorPos(cursorPos)没问题。
    难道是mouse对象造成了内存泄漏……
      

  7.   

    不太清楚
    没有去研究mouse的实现机制,可能是屏保的时候windows对于 mouse做了什么处理了吧?
      

  8.   

    回zhouzhangkui:
    我是在拦截WM_NCHITTEST消息中用的,程序中的问题已经通过lparam解决了。
    不过还是谢谢你!
    貌似是因为屏保ShowCursor(False)的时候,mouse对象估计没有考虑到这个问题吧~~
    偶再看看mouse的代码~确认一下。也谢谢"风雨"童鞋~~这么晚了把你拉过来顶贴~~嘿嘿·~帖子明天晚上结,看看还有高手发表看法没·~  #^_^#
      

  9.   

    明白了~~
    function TMouse.GetCursorPos: TPoint;
    begin
      Win32Check(Windows.GetCursorPos(Result));
    end;function Win32Check(RetVal: BOOL): BOOL;
    begin
      if not RetVal then RaiseLastOSError;
      Result := RetVal;
    end;屏保以后GetCursorPos返回False;所以delphi就憨憨的抛出了RaiseLastOSError。
    貌似就是这个问题!