type SSR_User = packed record PIN: word; Privilege: byte; Password: array[0..7] of byte; Name: array[0..23] of byte; Card: array[0..3] of byte; Group: byte; TimeZones: array[0..3] of word;//the timezones that the user can use PIN2: array[0..23] of byte; end;procedure GetSSRUserInfoFromDat(DataBuf: array of byte; var PIN, Privilege: integer; var Password, Name: string; var Card, Group: integer; var TimeZone, PIN2: string); var i: integer; PasswordBuf: array[0..7] of Char; NameBuf: array[0..23] of Char; TimeZoneBuf: array[0..7] of Char; PIN2Buf: array[0..23] of Char; ssruser: SSR_User; begin //ssruser = (SSR_User)Raw.RawDeserialize(DataBuf, typeof(3)); PIN := ssruser.PIN; Privilege := ssruser.Privilege; Move(DataBuf[3], PasswordBuf[0], 8); Password := StrPas(PasswordBuf); //"default" is to read the system's current ANSI code page encoding Move(DataBuf[11], NameBuf[0], 24); Name := StrPas(NameBuf); Card := 0; for i := 35 to 38 do Card := Card + Round(DataBuf[i] * Math.Power(16, 2 * (i - 35))); Group := ssruser.Group; Move(DataBuf[40], TimeZoneBuf[0], 8); TimeZone := StrPas(TimeZoneBuf); Move(DataBuf[48], PIN2Buf[0], 24); PIN2 := StrPas(PIN2Buf); end;
SSR_User = packed record
PIN: word;
Privilege: byte;
Password: array[0..7] of byte;
Name: array[0..23] of byte;
Card: array[0..3] of byte;
Group: byte;
TimeZones: array[0..3] of word;//the timezones that the user can use
PIN2: array[0..23] of byte;
end;procedure GetSSRUserInfoFromDat(DataBuf: array of byte;
var PIN, Privilege: integer;
var Password, Name: string;
var Card, Group: integer;
var TimeZone, PIN2: string);
var
i: integer;
PasswordBuf: array[0..7] of Char;
NameBuf: array[0..23] of Char;
TimeZoneBuf: array[0..7] of Char;
PIN2Buf: array[0..23] of Char;
ssruser: SSR_User;
begin
//ssruser = (SSR_User)Raw.RawDeserialize(DataBuf, typeof(3));
PIN := ssruser.PIN;
Privilege := ssruser.Privilege;
Move(DataBuf[3], PasswordBuf[0], 8);
Password := StrPas(PasswordBuf); //"default" is to read the system's current ANSI code page encoding
Move(DataBuf[11], NameBuf[0], 24);
Name := StrPas(NameBuf);
Card := 0;
for i := 35 to 38 do
Card := Card + Round(DataBuf[i] * Math.Power(16, 2 * (i - 35)));
Group := ssruser.Group; Move(DataBuf[40], TimeZoneBuf[0], 8);
TimeZone := StrPas(TimeZoneBuf); Move(DataBuf[48], PIN2Buf[0], 24);
PIN2 := StrPas(PIN2Buf);
end;
CopyMemory(@ssruser, @DataBuf[0], SizeOf(SSR_User)); PIN := ssruser.PIN;
Privilege := ssruser.Privilege;还查不到Raw.RawDeserialize这个函数的参数说明,我知道大致是强制转换的意思,所以暂时只能按上面的方式翻译下
{
int rawsize = Marshal.SizeOf(anytype);
if (rawsize > rawdatas.Length)
return null;
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.Copy(rawdatas, 0, buffer, rawsize);
object retobj = Marshal.PtrToStructure(buffer, anytype);
Marshal.FreeHGlobal(buffer);
return retobj;
}
表示类型声明:类类型、接口类型、数组类型、值类型、枚举类型、类型参数、泛型类型定义,以及开放或封闭构造的泛型类型。