//一种获取无符号整数最大值的方法:
procedure TForm1.Button1Click(Sender: TObject);
var
{Delphi 标准的无符号整数类型只有三种}
num_Byte : Byte;
num_Word : Word;
num_Cardinal : Cardinal;
{Windows API 中相应的类型就太多了, 下面是随便找了几种}
api_UCHAR : UCHAR; {Byte}
api_LANGID : LANGID; {Word}
api_DWORD : DWORD; {Cardinal}
api_LongWord : LongWord; {Cardinal}
api_UINT : UINT; {Cardinal}
api_THandle : THandle; {Cardinal}
api_HWND : HWND; {Cardinal}
begin
num_Byte := Byte(-1); ShowMessage(IntToStr(num_Byte)); {255}
num_Word := Word(-1); ShowMessage(IntToStr(num_Word)); {65535}
num_Cardinal := Cardinal(-1); ShowMessage(IntToStr(num_Cardinal)); {4294967295}
api_UCHAR := UCHAR(-1); ShowMessage(IntToStr(api_UCHAR)); {255}
api_LANGID := LANGID(-1); ShowMessage(IntToStr(api_LANGID)); {65535}
api_DWORD := DWORD(-1); ShowMessage(IntToStr(api_DWORD)); {4294967295}
api_LongWord := LongWord(-1); ShowMessage(IntToStr(api_LongWord)); {4294967295}
api_UINT := UINT(-1); ShowMessage(IntToStr(api_UINT)); {4294967295}
api_THandle := THandle(-1); ShowMessage(IntToStr(api_THandle)); {4294967295}
api_HWND := HWND(-1); ShowMessage(IntToStr(api_HWND)); {4294967295}
end;
相关文章: