2

以下の C++ の例を使用して、Delphi で DLL を作成しています。

USERDLL_API double process_message (const char* pmessage, const void* param) 
{
    if (pmessage==NULL) { return 0; }
    if (param==NULL) { return 0; }

    if (strcmp(pmessage,"state")==0) 
    { 
        current_state *state = (current_state*) param;
        return process_state( (current_state*)param ); 
    }
}

残念ながら、私は C++ とポインターについてほとんど知りません。char* (PChar?) と void* の代わりに何を使用すればよいですか?

function process_message (const pmessage: PChar; const param: ???): Double; export;
begin
    ???
end;

exports process_message;

関数の本体に関するヘルプも高く評価されます。私はそれがロケット科学ではないことを認識していますが、誰かが私のためにそれを行うのに十分親切であれば、数行を変換するためだけに C++ の基本を学ぶことはありません :-)

4

3 に答える 3

10

RAD Studioのオンラインドキュメントには 、C++コードをDelphiに変換するのに役立つDelphiからC++タイプへのマッピングテーブルが含まれています。

Delphi type         Platform    Corresponding C++ type

Boolean (Delphi)                bool (C++)
ShortInt (Delphi)               ShortInt, signed char (C++)
SmallInt (Delphi)               short (C++)
Integer (Delphi)                int (C++)
Byte (Delphi)                   Byte (C++)
Word (Delphi)                   Word (C++)
Cardinal (Delphi)               unsigned (C++)
Int64 (Delphi)                  __int64 (C++)
UInt64 (Delphi)                 unsigned __int64 (C++)
NativeInt (Delphi)  32-bit Win   int (C++)
                    64-bit Win  __int64 (C++)
                    64-bit iOS  long (C++)
NativeUInt (Delphi) 32-bit      unsigned (C++)
                    64-bit Win  unsigned __int64 (C++)
                    64-bit iOS  unsigned long (C++)
Single (Delphi)                 float (C++)
Double (Delphi)                 double (C++)
Extended (Delphi)               Extended (C++)
Currency (Delphi)               Currency, CurrencyBase (C++)
Comp (Delphi)                   Comp, CompBase (C++)
Real (Delphi)                   double (C++)
ShortString (Delphi)            ShortString, ShortStringBase (C++)
OpenString (Delphi)             OpenString (C++)
File (Delphi)                   file (C++)
Text (Delphi)                   TextFile (C++)
ByteBool (Delphi)               ByteBool (C++)
WordBool (Delphi)               WordBool (C++)
LongBool (Delphi)               BOOL (C++)
Real48 (Delphi)                 not supported in C++
Pointer (Delphi)                void* (C++)
PWideChar (Delphi)              WideChar* (C++)
PAnsiChar (Delphi)              char* (C++)
Variant (Delphi)                defined in sysvari.h (C++)
OleVariant (Delphi)             defined in sysvari.h (C++)
LongInt (Delphi)                int (C++)
                     64-bit iOS long (C++)
LongWord (Delphi)               unsigned (C++)
                     64-bit iOS unsigned long (C++)
FixedInt (Delphi)               int (C++)
FixedUInt (Delphi)              unsigned int (C++)
TextFile (Delphi)               TextFile (C++)
于 2009-09-14T08:39:59.810 に答える