如题, Struct如下:typedef struct _AdvancedStruct
{
  int (WINAPI *AddedFile)(char *lpFileName);
  int (WINAPI *AddedKey)(HKEY hKeyRoot,char *lpPath);
  int (WINAPI *AddedValue)(HKEY hKeyRoot,char *lpPath,char *
  lpValueName);
  int (WINAPI *AddShared)(char *lpSharedFile);
  int (WINAPI *BackupFile)(char *lpFileName);
  int (WINAPI *CreateDirectory)(char *lpDirectory);
  char * lpCommandLine;
  HBITMAP hbmDialog;
  BOOL bSilent;
  DWORD *lpdwFlags;
  char *(WINAPI *GetVariableString)(char *lpVariable);
  int (WINAPI *GetVariableInt)(char *lpVariable);
  int (WINAPI *SetVariableString)(char *lpVariable,char *
  lpValue);
  int (WINAPI *SetVariableInt)(char *lpVariable,int iValue);
} AdvancedStruct;

解决方案 »

  1.   

    在Delphi应该是Record吧type
      struct _AdvancedStruct = Record
          lpCommandLine : Char
    .
    .
    .end;
      

  2.   

    如果转为delphi的类也可以,c中Struct中的函数都是public中的,所以应该是下面的样子
    type
      struct _AdvancedStruct = class
      public
    然后把里面的函数写进去,会不会转函数呀?
     例如 int (WINAPI *AddedFile)(char *lpFileName);
    应该转为function AddedFile (lpFileName : pchar) : pointer;stdcall;
     stdcall是参数调用顺序,是从右到左调用,还可以用pascal,是从左到右调用参数 
    *AddedFile返回的是地址,如果需要,就另设一个变量,variants : integer; 
      variants = ^AddedFile();就行了,不知道这样说你明不明白?
    我的表达不好,请见谅!
      

  3.   

    非常感谢两位的回答。
    但我还不是很明白(基础不好啊),我主要是想把下面的代码转成delphi的typedef struct _AdvancedStruct
    {
      int (WINAPI *AddedFile)(char *lpFileName);
      int (WINAPI *AddedKey)(HKEY hKeyRoot,char *lpPath);
      int (WINAPI *AddedValue)(HKEY hKeyRoot,char *lpPath,char *lpValueName);
      int (WINAPI *AddShared)(char *lpSharedFile);
      int (WINAPI *BackupFile)(char *lpFileName);
      int (WINAPI *CreateDirectory)(char *lpDirectory);
      char *lpCommandLine;
      HBITMAP hbmDialog;
      BOOL bSilent;
      DWORD *lpdwFlags;
      char *(WINAPI *GetVariableString)(char *lpVariable);
      int (WINAPI *GetVariableInt)(char *lpVariable);
      int (WINAPI *SetVariableString)(char *lpVariable,char *lpValue);
      int (WINAPI *SetVariableInt)(char *lpVariable,int iValue);
    } AdvancedStruct;AdvancedStruct *g_pADS = NULL;long WINAPI AdvancedEntry(AdvancedStruct *lpAdvancedStruct)
    {
      g_pADS = lpAdvancedStruct;
      return 1;
    }
    具体怎么做?最好详细点,谢谢。
      

  4.   

    最终接受:
    type
      pAdvancedStruct = ^AdvancedStruct;
      _AdvancedStruct = packed record
        AddedFile:Function(lpFileName:PChar):Integer; stdcall;
        AddedKey:Function(hKeyRoot:HKEY; lpPath:PChar):Integer; stdcall;
        AddedValue:Function(hKeyRoot:HKEY; lpPath:PChar; lpValueName:PChar):Integer; stdcall;
        AddShared:Function(lpSharedFile:PChar):Integer; stdcall;
        BackupFile:Function(lpFileName:PChar):Integer; stdcall;
        CreateDirectory:Function(lpDirectory:PChar):Integer; stdcall;
        lpCommandLine:PChar;
        hbmDialog:HBITMAP;
        bSilent:Boolean;
        lpdwFlags:PDword;
        GetVariableString:Function(lpVariable:PChar):PChar; stdcall;
        GetVariableInt:Function(lpVariable:PChar):Integer; stdcall;
        SetVariableString:Function(lpVariable:PChar; lpValue:PChar):Integer; stdcall;
        SetVariableInt:Function(lpVariable:PChar; iValue:Integer):Integer; stdcall;
      end;
      AdvancedStruct = _AdvancedStruct;var
      g_pADS:pAdvancedStruct;Function AdvancedEntry(lpAdvancedStruct:pAdvancedStruct):LongWord; stdcall;
    begin
      g_pADS := lpAdvancedStruct;
      ResUlt := 1;
    end;