Maybe it's because GetFileAttributes returns DWORD (unsigned) but FileGetAttr's result is Longint (signed). When directory not exists result is DWORD(-1) = 0xFFFFFFFF which is outside of Longint range. -- cobines