請問如何將c的struct轉成pascal的record |
尚未結案
|
mhcjk
一般會員 發表:4 回覆:3 積分:1 註冊:2003-11-12 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
16 bit? far is useless in 32 bit Delphi... Please refer to your C compiler manul for this kind of defination.
type THostent = packed record h_name: PChar; h_aliases: PChar; h_addrtype: smallint; h_length: smallint; h_addr_list: PChar; end;Depends on your defination of short, you may need to adjust smallint type to other (like shortint). h_alias and h_addr are probably pointing to an array of string. |
mhcjk
一般會員 發表:4 回覆:3 積分:1 註冊:2003-11-12 發送簡訊給我 |
struct hostent {
char FAR * h_name;
char FAR * FAR * h_aliases;
short h_addrtype;
short h_length;
char FAR * FAR * h_addr_list;
} struct hostent FAR * gethostbyname ( const char FAR * name
); //sorry,一開始沒仔細寫清楚,我所call的是api,其原本的宣告如上。 type
PHostent =^THostent;
THostent = packed record
h_name: PChar;
h_aliases: PChar;
h_addrtype: Shortint;
h_length: Shortint;
h_addr_list: PChar;
end; function gethostbyname(const name:pchar):PHostent;stdcall;external 'ws2_32.dll'; 此為我以delphi所宣告的。執行後h_name確時可傳回正確的值,但其它的均伝回不正確的資料(可能無法正確對應到正確的位置)。 請大大們幫幫忙。
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
mhcjk
一般會員 發表:4 回覆:3 積分:1 註冊:2003-11-12 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |