CからPascalへの書き換え


よんよん  2005-03-22 01:06:58  No: 13871

あるDLLを使うためのサンプルコードがCで書かれているので
それをDelphi(6 personal)から使おうとしているのですが、
エラー(メモリアクセス違反)がでて止まってしまいます。
下のコードをDelphiで動くように書き換えるにはどのようにすればいいのでしょうか?
ご教授お願いします。

--------------------------------------------------------------
{C}
enum X_STATUS { 
    X_SUCCESS = 0, 
    X_FAIL = 0x31000001, 
}; 
typedef void (__cdecl *X_CALLBACK)(X_HANDLE handle, void *context);
typedef struct X_CALLBACK_OPS

    X_CALLBACK cbConnect;
    X_CALLBACK cbDisconnect;
} X_CALLBACK_OPS;

DllExport X_STATUS X_Init(X_HANDLE *handle, unsigned short xid, void *context, X_CALLBACK_OPS *ops);
--------------------------------------------------------------

{Delphi (object pascal)}
type
  X_STATUS = ( 
    X_SUCCESS = 0, 
    X_FAIL = $31000001, 
    );
type X_CALLBACK = procedure(handle:X_HANDLE; context:Pointer); cdecl;
type
  X_CALLBACK_OPS = record
    cbConnect     : ^X_CALLBACK;
    cbDisconnect  : ^X_CALLBACK;
end;
type PX_CALLBACK_OPS = ^X_CALLBACK_OPS;

function X_Init(handle:PX_HANDLE; xid:Word; context:Pointer; ops:PX_CALLBACK_OPS) : X_STATUS; stdcall;
  external 'Xlib.dll';
--------------------------------------------------------------


※返信する前に利用規約をご確認ください。

※Google reCAPTCHA認証からCloudflare Turnstile認証へ変更しました。






  このエントリーをはてなブックマークに追加